Java Code Examples for java.awt.event.KeyEvent#VK_STOP

The following examples show how to use java.awt.event.KeyEvent#VK_STOP . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KeyStrokeUtils.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Sort the list, so that the most appropriate accelerator is at index 0.
 */
private static List<KeyStroke[]> sortKeyStrokesByPreference(
        List<KeyStroke[]> keystrokes) {
    if (keystrokes.size() < 2) {
        return keystrokes;
    }
    KeyStroke best[] = null;
    boolean isSolaris =
            Utilities.getOperatingSystem() == Utilities.OS_SOLARIS;
    for (int i = 0; i < keystrokes.size(); i++) {
        KeyStroke[] ks = keystrokes.get(i);
        if (ks.length > 1) {
            continue;
        }
        boolean solarisKey = ks[0].getKeyCode() >= KeyEvent.VK_STOP
                && ks[0].getKeyCode() <= KeyEvent.VK_CUT;
        if (isSolaris == solarisKey
                && (best == null
                || best[0].getKeyCode() > ks[0].getKeyCode())) {
            //Solaris key on solaris OS or other key on other OS.
            best = ks;
        }
    }
    if (best != null) {
        keystrokes.remove(best);
        keystrokes.add(0, best);
    }
    return keystrokes;
}