Example usage for java.awt.event KeyEvent VK_RIGHT

List of usage examples for java.awt.event KeyEvent VK_RIGHT

Introduction

In this page you can find the example usage for java.awt.event KeyEvent VK_RIGHT.

Prototype

int VK_RIGHT

To view the source code for java.awt.event KeyEvent VK_RIGHT.

Click Source Link

Document

Constant for the non-numpad right arrow key.

Usage

From source file:Main.java

static String getKeyText(int keyCode) {
    if (keyCode >= KeyEvent.VK_0 && keyCode <= KeyEvent.VK_9
            || keyCode >= KeyEvent.VK_A && keyCode <= KeyEvent.VK_Z) {
        return String.valueOf((char) keyCode);
    }//from  ww  w. ja  v a  2  s. c o m
    switch (keyCode) {
    case KeyEvent.VK_COMMA:
        return "COMMA";
    case KeyEvent.VK_PERIOD:
        return "PERIOD";
    case KeyEvent.VK_SLASH:
        return "SLASH";
    case KeyEvent.VK_SEMICOLON:
        return "SEMICOLON";
    case KeyEvent.VK_EQUALS:
        return "EQUALS";
    case KeyEvent.VK_OPEN_BRACKET:
        return "OPEN_BRACKET";
    case KeyEvent.VK_BACK_SLASH:
        return "BACK_SLASH";
    case KeyEvent.VK_CLOSE_BRACKET:
        return "CLOSE_BRACKET";
    case KeyEvent.VK_ENTER:
        return "ENTER";
    case KeyEvent.VK_BACK_SPACE:
        return "BACK_SPACE";
    case KeyEvent.VK_TAB:
        return "TAB";
    case KeyEvent.VK_CANCEL:
        return "CANCEL";
    case KeyEvent.VK_CLEAR:
        return "CLEAR";
    case KeyEvent.VK_SHIFT:
        return "SHIFT";
    case KeyEvent.VK_CONTROL:
        return "CONTROL";
    case KeyEvent.VK_ALT:
        return "ALT";
    case KeyEvent.VK_PAUSE:
        return "PAUSE";
    case KeyEvent.VK_CAPS_LOCK:
        return "CAPS_LOCK";
    case KeyEvent.VK_ESCAPE:
        return "ESCAPE";
    case KeyEvent.VK_SPACE:
        return "SPACE";
    case KeyEvent.VK_PAGE_UP:
        return "PAGE_UP";
    case KeyEvent.VK_PAGE_DOWN:
        return "PAGE_DOWN";
    case KeyEvent.VK_END:
        return "END";
    case KeyEvent.VK_HOME:
        return "HOME";
    case KeyEvent.VK_LEFT:
        return "LEFT";
    case KeyEvent.VK_UP:
        return "UP";
    case KeyEvent.VK_RIGHT:
        return "RIGHT";
    case KeyEvent.VK_DOWN:
        return "DOWN";
    case KeyEvent.VK_MULTIPLY:
        return "MULTIPLY";
    case KeyEvent.VK_ADD:
        return "ADD";
    case KeyEvent.VK_SEPARATOR:
        return "SEPARATOR";
    case KeyEvent.VK_SUBTRACT:
        return "SUBTRACT";
    case KeyEvent.VK_DECIMAL:
        return "DECIMAL";
    case KeyEvent.VK_DIVIDE:
        return "DIVIDE";
    case KeyEvent.VK_DELETE:
        return "DELETE";
    case KeyEvent.VK_NUM_LOCK:
        return "NUM_LOCK";
    case KeyEvent.VK_SCROLL_LOCK:
        return "SCROLL_LOCK";
    case KeyEvent.VK_F1:
        return "F1";
    case KeyEvent.VK_F2:
        return "F2";
    case KeyEvent.VK_F3:
        return "F3";
    case KeyEvent.VK_F4:
        return "F4";
    case KeyEvent.VK_F5:
        return "F5";
    case KeyEvent.VK_F6:
        return "F6";
    case KeyEvent.VK_F7:
        return "F7";
    case KeyEvent.VK_F8:
        return "F8";
    case KeyEvent.VK_F9:
        return "F9";
    case KeyEvent.VK_F10:
        return "F10";
    case KeyEvent.VK_F11:
        return "F11";
    case KeyEvent.VK_F12:
        return "F12";
    case KeyEvent.VK_F13:
        return "F13";
    case KeyEvent.VK_F14:
        return "F14";
    case KeyEvent.VK_F15:
        return "F15";
    case KeyEvent.VK_F16:
        return "F16";
    case KeyEvent.VK_F17:
        return "F17";
    case KeyEvent.VK_F18:
        return "F18";
    case KeyEvent.VK_F19:
        return "F19";
    case KeyEvent.VK_F20:
        return "F20";
    case KeyEvent.VK_F21:
        return "F21";
    case KeyEvent.VK_F22:
        return "F22";
    case KeyEvent.VK_F23:
        return "F23";
    case KeyEvent.VK_F24:
        return "F24";
    case KeyEvent.VK_PRINTSCREEN:
        return "PRINTSCREEN";
    case KeyEvent.VK_INSERT:
        return "INSERT";
    case KeyEvent.VK_HELP:
        return "HELP";
    case KeyEvent.VK_META:
        return "META";
    case KeyEvent.VK_BACK_QUOTE:
        return "BACK_QUOTE";
    case KeyEvent.VK_QUOTE:
        return "QUOTE";
    case KeyEvent.VK_KP_UP:
        return "KP_UP";
    case KeyEvent.VK_KP_DOWN:
        return "KP_DOWN";
    case KeyEvent.VK_KP_LEFT:
        return "KP_LEFT";
    case KeyEvent.VK_KP_RIGHT:
        return "KP_RIGHT";
    case KeyEvent.VK_DEAD_GRAVE:
        return "DEAD_GRAVE";
    case KeyEvent.VK_DEAD_ACUTE:
        return "DEAD_ACUTE";
    case KeyEvent.VK_DEAD_CIRCUMFLEX:
        return "DEAD_CIRCUMFLEX";
    case KeyEvent.VK_DEAD_TILDE:
        return "DEAD_TILDE";
    case KeyEvent.VK_DEAD_MACRON:
        return "DEAD_MACRON";
    case KeyEvent.VK_DEAD_BREVE:
        return "DEAD_BREVE";
    case KeyEvent.VK_DEAD_ABOVEDOT:
        return "DEAD_ABOVEDOT";
    case KeyEvent.VK_DEAD_DIAERESIS:
        return "DEAD_DIAERESIS";
    case KeyEvent.VK_DEAD_ABOVERING:
        return "DEAD_ABOVERING";
    case KeyEvent.VK_DEAD_DOUBLEACUTE:
        return "DEAD_DOUBLEACUTE";
    case KeyEvent.VK_DEAD_CARON:
        return "DEAD_CARON";
    case KeyEvent.VK_DEAD_CEDILLA:
        return "DEAD_CEDILLA";
    case KeyEvent.VK_DEAD_OGONEK:
        return "DEAD_OGONEK";
    case KeyEvent.VK_DEAD_IOTA:
        return "DEAD_IOTA";
    case KeyEvent.VK_DEAD_VOICED_SOUND:
        return "DEAD_VOICED_SOUND";
    case KeyEvent.VK_DEAD_SEMIVOICED_SOUND:
        return "DEAD_SEMIVOICED_SOUND";
    case KeyEvent.VK_AMPERSAND:
        return "AMPERSAND";
    case KeyEvent.VK_ASTERISK:
        return "ASTERISK";
    case KeyEvent.VK_QUOTEDBL:
        return "QUOTEDBL";
    case KeyEvent.VK_LESS:
        return "LESS";
    case KeyEvent.VK_GREATER:
        return "GREATER";
    case KeyEvent.VK_BRACELEFT:
        return "BRACELEFT";
    case KeyEvent.VK_BRACERIGHT:
        return "BRACERIGHT";
    case KeyEvent.VK_AT:
        return "AT";
    case KeyEvent.VK_COLON:
        return "COLON";
    case KeyEvent.VK_CIRCUMFLEX:
        return "CIRCUMFLEX";
    case KeyEvent.VK_DOLLAR:
        return "DOLLAR";
    case KeyEvent.VK_EURO_SIGN:
        return "EURO_SIGN";
    case KeyEvent.VK_EXCLAMATION_MARK:
        return "EXCLAMATION_MARK";
    case KeyEvent.VK_INVERTED_EXCLAMATION_MARK:
        return "INVERTED_EXCLAMATION_MARK";
    case KeyEvent.VK_LEFT_PARENTHESIS:
        return "LEFT_PARENTHESIS";
    case KeyEvent.VK_NUMBER_SIGN:
        return "NUMBER_SIGN";
    case KeyEvent.VK_MINUS:
        return "MINUS";
    case KeyEvent.VK_PLUS:
        return "PLUS";
    case KeyEvent.VK_RIGHT_PARENTHESIS:
        return "RIGHT_PARENTHESIS";
    case KeyEvent.VK_UNDERSCORE:
        return "UNDERSCORE";
    case KeyEvent.VK_FINAL:
        return "FINAL";
    case KeyEvent.VK_CONVERT:
        return "CONVERT";
    case KeyEvent.VK_NONCONVERT:
        return "NONCONVERT";
    case KeyEvent.VK_ACCEPT:
        return "ACCEPT";
    case KeyEvent.VK_MODECHANGE:
        return "MODECHANGE";
    case KeyEvent.VK_KANA:
        return "KANA";
    case KeyEvent.VK_KANJI:
        return "KANJI";
    case KeyEvent.VK_ALPHANUMERIC:
        return "ALPHANUMERIC";
    case KeyEvent.VK_KATAKANA:
        return "KATAKANA";
    case KeyEvent.VK_HIRAGANA:
        return "HIRAGANA";
    case KeyEvent.VK_FULL_WIDTH:
        return "FULL_WIDTH";
    case KeyEvent.VK_HALF_WIDTH:
        return "HALF_WIDTH";
    case KeyEvent.VK_ROMAN_CHARACTERS:
        return "ROMAN_CHARACTERS";
    case KeyEvent.VK_ALL_CANDIDATES:
        return "ALL_CANDIDATES";
    case KeyEvent.VK_PREVIOUS_CANDIDATE:
        return "PREVIOUS_CANDIDATE";
    case KeyEvent.VK_CODE_INPUT:
        return "CODE_INPUT";
    case KeyEvent.VK_JAPANESE_KATAKANA:
        return "JAPANESE_KATAKANA";
    case KeyEvent.VK_JAPANESE_HIRAGANA:
        return "JAPANESE_HIRAGANA";
    case KeyEvent.VK_JAPANESE_ROMAN:
        return "JAPANESE_ROMAN";
    case KeyEvent.VK_KANA_LOCK:
        return "KANA_LOCK";
    case KeyEvent.VK_INPUT_METHOD_ON_OFF:
        return "INPUT_METHOD_ON_OFF";

    case KeyEvent.VK_AGAIN:
        return "AGAIN";
    case KeyEvent.VK_UNDO:
        return "UNDO";
    case KeyEvent.VK_COPY:
        return "COPY";
    case KeyEvent.VK_PASTE:
        return "PASTE";
    case KeyEvent.VK_CUT:
        return "CUT";
    case KeyEvent.VK_FIND:
        return "FIND";
    case KeyEvent.VK_PROPS:
        return "PROPS";
    case KeyEvent.VK_STOP:
        return "STOP";

    case KeyEvent.VK_COMPOSE:
        return "COMPOSE";
    case KeyEvent.VK_ALT_GRAPH:
        return "ALT_GRAPH";
    }

    if (keyCode >= KeyEvent.VK_NUMPAD0 && keyCode <= KeyEvent.VK_NUMPAD9) {
        char c = (char) (keyCode - KeyEvent.VK_NUMPAD0 + '0');
        return "NUMPAD" + c;
    }

    return "unknown(0x" + Integer.toString(keyCode, 16) + ")";
}

From source file:Main.java

static String getKeyText(int keyCode) {
    if (keyCode >= KeyEvent.VK_0 && keyCode <= KeyEvent.VK_9
            || keyCode >= KeyEvent.VK_A && keyCode <= KeyEvent.VK_Z) {
        return String.valueOf((char) keyCode);
    }/* w w  w.j a v a 2 s  .c  om*/
    switch (keyCode) {
    case KeyEvent.VK_COMMA:
        return "COMMA";
    case KeyEvent.VK_PERIOD:
        return "PERIOD";
    case KeyEvent.VK_SLASH:
        return "SLASH";
    case KeyEvent.VK_SEMICOLON:
        return "SEMICOLON";
    case KeyEvent.VK_EQUALS:
        return "EQUALS";
    case KeyEvent.VK_OPEN_BRACKET:
        return "OPEN_BRACKET";
    case KeyEvent.VK_BACK_SLASH:
        return "BACK_SLASH";
    case KeyEvent.VK_CLOSE_BRACKET:
        return "CLOSE_BRACKET";
    case KeyEvent.VK_ENTER:
        return "ENTER";
    case KeyEvent.VK_BACK_SPACE:
        return "BACK_SPACE";
    case KeyEvent.VK_TAB:
        return "TAB";
    case KeyEvent.VK_CANCEL:
        return "CANCEL";
    case KeyEvent.VK_CLEAR:
        return "CLEAR";
    case KeyEvent.VK_SHIFT:
        return "SHIFT";
    case KeyEvent.VK_CONTROL:
        return "CONTROL";
    case KeyEvent.VK_ALT:
        return "ALT";
    case KeyEvent.VK_PAUSE:
        return "PAUSE";
    case KeyEvent.VK_CAPS_LOCK:
        return "CAPS_LOCK";
    case KeyEvent.VK_ESCAPE:
        return "ESCAPE";
    case KeyEvent.VK_SPACE:
        return "SPACE";
    case KeyEvent.VK_PAGE_UP:
        return "PAGE_UP";
    case KeyEvent.VK_PAGE_DOWN:
        return "PAGE_DOWN";
    case KeyEvent.VK_END:
        return "END";
    case KeyEvent.VK_HOME:
        return "HOME";
    case KeyEvent.VK_LEFT:
        return "LEFT";
    case KeyEvent.VK_UP:
        return "UP";
    case KeyEvent.VK_RIGHT:
        return "RIGHT";
    case KeyEvent.VK_DOWN:
        return "DOWN";
    // numpad numeric keys handled below
    case KeyEvent.VK_MULTIPLY:
        return "MULTIPLY";
    case KeyEvent.VK_ADD:
        return "ADD";
    case KeyEvent.VK_SEPARATOR:
        return "SEPARATOR";
    case KeyEvent.VK_SUBTRACT:
        return "SUBTRACT";
    case KeyEvent.VK_DECIMAL:
        return "DECIMAL";
    case KeyEvent.VK_DIVIDE:
        return "DIVIDE";
    case KeyEvent.VK_DELETE:
        return "DELETE";
    case KeyEvent.VK_NUM_LOCK:
        return "NUM_LOCK";
    case KeyEvent.VK_SCROLL_LOCK:
        return "SCROLL_LOCK";
    case KeyEvent.VK_F1:
        return "F1";
    case KeyEvent.VK_F2:
        return "F2";
    case KeyEvent.VK_F3:
        return "F3";
    case KeyEvent.VK_F4:
        return "F4";
    case KeyEvent.VK_F5:
        return "F5";
    case KeyEvent.VK_F6:
        return "F6";
    case KeyEvent.VK_F7:
        return "F7";
    case KeyEvent.VK_F8:
        return "F8";
    case KeyEvent.VK_F9:
        return "F9";
    case KeyEvent.VK_F10:
        return "F10";
    case KeyEvent.VK_F11:
        return "F11";
    case KeyEvent.VK_F12:
        return "F12";
    case KeyEvent.VK_F13:
        return "F13";
    case KeyEvent.VK_F14:
        return "F14";
    case KeyEvent.VK_F15:
        return "F15";
    case KeyEvent.VK_F16:
        return "F16";
    case KeyEvent.VK_F17:
        return "F17";
    case KeyEvent.VK_F18:
        return "F18";
    case KeyEvent.VK_F19:
        return "F19";
    case KeyEvent.VK_F20:
        return "F20";
    case KeyEvent.VK_F21:
        return "F21";
    case KeyEvent.VK_F22:
        return "F22";
    case KeyEvent.VK_F23:
        return "F23";
    case KeyEvent.VK_F24:
        return "F24";
    case KeyEvent.VK_PRINTSCREEN:
        return "PRINTSCREEN";
    case KeyEvent.VK_INSERT:
        return "INSERT";
    case KeyEvent.VK_HELP:
        return "HELP";
    case KeyEvent.VK_META:
        return "META";
    case KeyEvent.VK_BACK_QUOTE:
        return "BACK_QUOTE";
    case KeyEvent.VK_QUOTE:
        return "QUOTE";
    case KeyEvent.VK_KP_UP:
        return "KP_UP";
    case KeyEvent.VK_KP_DOWN:
        return "KP_DOWN";
    case KeyEvent.VK_KP_LEFT:
        return "KP_LEFT";
    case KeyEvent.VK_KP_RIGHT:
        return "KP_RIGHT";
    case KeyEvent.VK_DEAD_GRAVE:
        return "DEAD_GRAVE";
    case KeyEvent.VK_DEAD_ACUTE:
        return "DEAD_ACUTE";
    case KeyEvent.VK_DEAD_CIRCUMFLEX:
        return "DEAD_CIRCUMFLEX";
    case KeyEvent.VK_DEAD_TILDE:
        return "DEAD_TILDE";
    case KeyEvent.VK_DEAD_MACRON:
        return "DEAD_MACRON";
    case KeyEvent.VK_DEAD_BREVE:
        return "DEAD_BREVE";
    case KeyEvent.VK_DEAD_ABOVEDOT:
        return "DEAD_ABOVEDOT";
    case KeyEvent.VK_DEAD_DIAERESIS:
        return "DEAD_DIAERESIS";
    case KeyEvent.VK_DEAD_ABOVERING:
        return "DEAD_ABOVERING";
    case KeyEvent.VK_DEAD_DOUBLEACUTE:
        return "DEAD_DOUBLEACUTE";
    case KeyEvent.VK_DEAD_CARON:
        return "DEAD_CARON";
    case KeyEvent.VK_DEAD_CEDILLA:
        return "DEAD_CEDILLA";
    case KeyEvent.VK_DEAD_OGONEK:
        return "DEAD_OGONEK";
    case KeyEvent.VK_DEAD_IOTA:
        return "DEAD_IOTA";
    case KeyEvent.VK_DEAD_VOICED_SOUND:
        return "DEAD_VOICED_SOUND";
    case KeyEvent.VK_DEAD_SEMIVOICED_SOUND:
        return "DEAD_SEMIVOICED_SOUND";
    case KeyEvent.VK_AMPERSAND:
        return "AMPERSAND";
    case KeyEvent.VK_ASTERISK:
        return "ASTERISK";
    case KeyEvent.VK_QUOTEDBL:
        return "QUOTEDBL";
    case KeyEvent.VK_LESS:
        return "LESS";
    case KeyEvent.VK_GREATER:
        return "GREATER";
    case KeyEvent.VK_BRACELEFT:
        return "BRACELEFT";
    case KeyEvent.VK_BRACERIGHT:
        return "BRACERIGHT";
    case KeyEvent.VK_AT:
        return "AT";
    case KeyEvent.VK_COLON:
        return "COLON";
    case KeyEvent.VK_CIRCUMFLEX:
        return "CIRCUMFLEX";
    case KeyEvent.VK_DOLLAR:
        return "DOLLAR";
    case KeyEvent.VK_EURO_SIGN:
        return "EURO_SIGN";
    case KeyEvent.VK_EXCLAMATION_MARK:
        return "EXCLAMATION_MARK";
    case KeyEvent.VK_INVERTED_EXCLAMATION_MARK:
        return "INVERTED_EXCLAMATION_MARK";
    case KeyEvent.VK_LEFT_PARENTHESIS:
        return "LEFT_PARENTHESIS";
    case KeyEvent.VK_NUMBER_SIGN:
        return "NUMBER_SIGN";
    case KeyEvent.VK_MINUS:
        return "MINUS";
    case KeyEvent.VK_PLUS:
        return "PLUS";
    case KeyEvent.VK_RIGHT_PARENTHESIS:
        return "RIGHT_PARENTHESIS";
    case KeyEvent.VK_UNDERSCORE:
        return "UNDERSCORE";
    case KeyEvent.VK_FINAL:
        return "FINAL";
    case KeyEvent.VK_CONVERT:
        return "CONVERT";
    case KeyEvent.VK_NONCONVERT:
        return "NONCONVERT";
    case KeyEvent.VK_ACCEPT:
        return "ACCEPT";
    case KeyEvent.VK_MODECHANGE:
        return "MODECHANGE";
    case KeyEvent.VK_KANA:
        return "KANA";
    case KeyEvent.VK_KANJI:
        return "KANJI";
    case KeyEvent.VK_ALPHANUMERIC:
        return "ALPHANUMERIC";
    case KeyEvent.VK_KATAKANA:
        return "KATAKANA";
    case KeyEvent.VK_HIRAGANA:
        return "HIRAGANA";
    case KeyEvent.VK_FULL_WIDTH:
        return "FULL_WIDTH";
    case KeyEvent.VK_HALF_WIDTH:
        return "HALF_WIDTH";
    case KeyEvent.VK_ROMAN_CHARACTERS:
        return "ROMAN_CHARACTERS";
    case KeyEvent.VK_ALL_CANDIDATES:
        return "ALL_CANDIDATES";
    case KeyEvent.VK_PREVIOUS_CANDIDATE:
        return "PREVIOUS_CANDIDATE";
    case KeyEvent.VK_CODE_INPUT:
        return "CODE_INPUT";
    case KeyEvent.VK_JAPANESE_KATAKANA:
        return "JAPANESE_KATAKANA";
    case KeyEvent.VK_JAPANESE_HIRAGANA:
        return "JAPANESE_HIRAGANA";
    case KeyEvent.VK_JAPANESE_ROMAN:
        return "JAPANESE_ROMAN";
    case KeyEvent.VK_KANA_LOCK:
        return "KANA_LOCK";
    case KeyEvent.VK_INPUT_METHOD_ON_OFF:
        return "INPUT_METHOD_ON_OFF";

    case KeyEvent.VK_AGAIN:
        return "AGAIN";
    case KeyEvent.VK_UNDO:
        return "UNDO";
    case KeyEvent.VK_COPY:
        return "COPY";
    case KeyEvent.VK_PASTE:
        return "PASTE";
    case KeyEvent.VK_CUT:
        return "CUT";
    case KeyEvent.VK_FIND:
        return "FIND";
    case KeyEvent.VK_PROPS:
        return "PROPS";
    case KeyEvent.VK_STOP:
        return "STOP";

    case KeyEvent.VK_COMPOSE:
        return "COMPOSE";
    case KeyEvent.VK_ALT_GRAPH:
        return "ALT_GRAPH";
    }

    if (keyCode >= KeyEvent.VK_NUMPAD0 && keyCode <= KeyEvent.VK_NUMPAD9) {
        char c = (char) (keyCode - KeyEvent.VK_NUMPAD0 + '0');
        return "NUMPAD" + c;
    }

    return "unknown(0x" + Integer.toString(keyCode, 16) + ")";
}

From source file:CodePointInputMethod.java

/**
 * This is the input method's main routine.  The composed text is stored
 * in buffer.//from   w  w  w .ja v a  2s .  co m
 */
public void dispatchEvent(AWTEvent event) {
    // This input method handles KeyEvent only.
    if (!(event instanceof KeyEvent)) {
        return;
    }

    KeyEvent e = (KeyEvent) event;
    int eventID = event.getID();
    boolean notInCompositionMode = buffer.length() == 0;

    if (eventID == KeyEvent.KEY_PRESSED) {
        // If we are not in composition mode, pass through
        if (notInCompositionMode) {
            return;
        }

        switch (e.getKeyCode()) {
        case KeyEvent.VK_LEFT:
            moveCaretLeft();
            break;
        case KeyEvent.VK_RIGHT:
            moveCaretRight();
            break;
        }
    } else if (eventID == KeyEvent.KEY_TYPED) {
        char c = e.getKeyChar();

        // If we are not in composition mode, wait a back slash
        if (notInCompositionMode) {
            // If the type character is not a back slash, pass through
            if (c != '\\') {
                return;
            }

            startComposition(); // Enter to composition mode
        } else {
            switch (c) {
            case ' ': // Exit from composition mode
                finishComposition();
                break;
            case '\u007f': // Delete
                deleteCharacter();
                break;
            case '\b': // BackSpace
                deletePreviousCharacter();
                break;
            case '\u001b': // Escape
                cancelComposition();
                break;
            case '\n': // Return
            case '\t': // Tab
                sendCommittedText();
                break;
            default:
                composeUnicodeEscape(c);
                break;
            }
        }
    } else { // KeyEvent.KEY_RELEASED
        // If we are not in composition mode, pass through
        if (notInCompositionMode) {
            return;
        }
    }

    e.consume();
}

From source file:org.jcodec.player.app.PlayerMain.java

public void keyPressed(KeyEvent e) {
    if (e.getKeyCode() == KeyEvent.VK_SPACE) {
        if (player.getStatus() == Player.Status.PAUSED) {
            if (stepper != null) {
                player.seek(stepper.getPos());
                stepper = null;//w ww .  j  a  v a 2 s .  c  o m
            }
            player.play();
        } else
            player.pause();
    } else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
        RationalLarge pos = player.getPos();
        player.seek(new RationalLarge(pos.getNum() - pos.getDen() * 15, pos.getDen()));
    } else if (e.getKeyCode() == KeyEvent.VK_UP) {
        RationalLarge pos = player.getPos();
        player.seek(new RationalLarge(pos.getNum() + pos.getDen() * 15, pos.getDen()));
    } else if (e.getKeyCode() == KeyEvent.VK_LEFT) {
        // if (player.getStatus() != Player.Status.PAUSED) {
        // player.pause();
        // return;
        // }
        //
        // try {
        // if (stepper == null) {
        // stepper = new Stepper(video, mixer, vo, new JSoundAudioOut());
        // stepper.setListeners(player.getListeners());
        // stepper.gotoFrame(player.getFrameNo());
        // }
        // stepper.prev();
        // } catch (IOException e1) {
        // System.out.println("Couldn't step " + e1.getMessage());
        // }
    } else if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
        if (player.getStatus() != Player.Status.PAUSED) {
            player.pause();
            return;
        }
        try {
            if (stepper == null) {
                stepper = new Stepper(video, mixer, vo, new JSoundAudioOut());
                stepper.setListeners(player.getListeners());
                stepper.gotoFrame(player.getFrameNo());
            }
            stepper.next();
        } catch (IOException e1) {
            System.out.println("Couldn't step " + e1.getMessage());
        }
    } else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
        player.destroy();
        System.exit(-1);
    } else if (e.getKeyChar() >= '0' && e.getKeyChar() < '9') {
        int ch = e.getKeyChar() - '0';
        for (Pin pin : mixer.getPins()) {
            if (ch < pin.getLabels().length) {
                pin.toggle(ch);
                break;
            } else
                ch -= pin.getLabels().length;
        }
    }
}

From source file:com.mucommander.ui.viewer.image.ImageViewer.java

public ImageViewer() {
    imageViewerImpl = new ImageViewerImpl();

    setComponentToPresent(imageViewerImpl);

    // create Go menu
    MnemonicHelper menuMnemonicHelper = new MnemonicHelper();
    controlsMenu = MenuToolkit.addMenu(Translator.get("image_viewer.controls_menu"), menuMnemonicHelper, null);

    nextImageItem = MenuToolkit.addMenuItem(controlsMenu, Translator.get("image_viewer.next_image"),
            menuMnemonicHelper, KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0), this);
    prevImageItem = MenuToolkit.addMenuItem(controlsMenu, Translator.get("image_viewer.previous_image"),
            menuMnemonicHelper, KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0), this);
    controlsMenu.add(new JSeparator());
    if (OsFamily.getCurrent() != OsFamily.MAC_OS_X) {
        zoomInItem = MenuToolkit.addMenuItem(controlsMenu, Translator.get("image_viewer.zoom_in"),
                menuMnemonicHelper, KeyStroke.getKeyStroke(KeyEvent.VK_ADD, 0), this);
        zoomOutItem = MenuToolkit.addMenuItem(controlsMenu, Translator.get("image_viewer.zoom_out"),
                menuMnemonicHelper, KeyStroke.getKeyStroke(KeyEvent.VK_SUBTRACT, 0), this);
    } else {//from   w  ww. j a  v  a  2 s  .c o  m
        zoomInItem = MenuToolkit.addMenuItem(controlsMenu, Translator.get("image_viewer.zoom_in"),
                menuMnemonicHelper, KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), this);
        zoomOutItem = MenuToolkit.addMenuItem(controlsMenu, Translator.get("image_viewer.zoom_out"),
                menuMnemonicHelper, KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), this);
    }
}

From source file:com.mirth.connect.client.ui.Mirth.java

/**
 * Create the alternate key bindings for the menu shortcut key mask. This is called if the menu
 * shortcut key mask is not the CTRL key (i.e. COMMAND on OSX)
 *//*from w ww . j  a  v a 2 s.  c  o m*/
private static void createAlternateKeyBindings() {
    int acceleratorKey = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
    // Add the common KeyBindings for macs
    KeyBinding[] defaultBindings = {
            new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_C, acceleratorKey), DefaultEditorKit.copyAction),
            new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_V, acceleratorKey), DefaultEditorKit.pasteAction),
            new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_X, acceleratorKey), DefaultEditorKit.cutAction),
            new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_A, acceleratorKey),
                    DefaultEditorKit.selectAllAction),
            // deleteNextWordAction and deletePrevWordAction were not available in Java 1.5
            new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, acceleratorKey),
                    DefaultEditorKit.deleteNextWordAction),
            new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, acceleratorKey),
                    DefaultEditorKit.deletePrevWordAction),
            new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, acceleratorKey),
                    DefaultEditorKit.nextWordAction),
            new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_KP_RIGHT, acceleratorKey),
                    DefaultEditorKit.nextWordAction),
            new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, acceleratorKey),
                    DefaultEditorKit.previousWordAction),
            new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_KP_LEFT, acceleratorKey),
                    DefaultEditorKit.previousWordAction),
            new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, acceleratorKey | InputEvent.SHIFT_MASK),
                    DefaultEditorKit.selectionNextWordAction),
            new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_KP_RIGHT, acceleratorKey | InputEvent.SHIFT_MASK),
                    DefaultEditorKit.selectionNextWordAction),
            new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, acceleratorKey | InputEvent.SHIFT_MASK),
                    DefaultEditorKit.selectionPreviousWordAction),
            new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_KP_LEFT, acceleratorKey | InputEvent.SHIFT_MASK),
                    DefaultEditorKit.selectionPreviousWordAction) };

    keyMapBindings(new javax.swing.JTextField(), defaultBindings);
    keyMapBindings(new javax.swing.JPasswordField(), defaultBindings);
    keyMapBindings(new javax.swing.JTextPane(), defaultBindings);
    keyMapBindings(new javax.swing.JTextArea(), defaultBindings);
    keyMapBindings(new com.mirth.connect.client.ui.components.MirthTextField(), defaultBindings);
    keyMapBindings(new com.mirth.connect.client.ui.components.MirthPasswordField(), defaultBindings);
    keyMapBindings(new com.mirth.connect.client.ui.components.MirthTextPane(), defaultBindings);
    keyMapBindings(new com.mirth.connect.client.ui.components.MirthTextArea(), defaultBindings);
}

From source file:JXButtonPanel.java

private void init() {
    setFocusTraversalPolicyProvider(true);
    setFocusTraversalPolicy(new JXButtonPanelFocusTraversalPolicy());
    ActionListener actionHandler = new ActionHandler();
    registerKeyboardAction(actionHandler, ActionHandler.FORWARD, KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0),
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    registerKeyboardAction(actionHandler, ActionHandler.FORWARD, KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0),
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    registerKeyboardAction(actionHandler, ActionHandler.BACKWARD, KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0),
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    registerKeyboardAction(actionHandler, ActionHandler.BACKWARD, KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0),
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    setGroupSelectionFollowFocus(true);// w  w  w  .ja  v  a2s.c  o  m
}

From source file:com.fanniemae.ezpie.actions.HighlightScan.java

private void changeOracleExtractExtension(File castExtractionFile) {
    ProcessBuilder pb = new ProcessBuilder("java", "-jar", _dbDeliveryToolPath);
    Process process = null;//from  ww  w. j a v  a 2  s  .  c o  m
    Robot robot = null;
    try {
        process = pb.start();
        robot = new Robot();
    } catch (IOException | AWTException e) {
        throw new PieException("Could not start Oracle extract.", e);
    }

    sleep(15000);
    // navigating to input text
    for (int i = 0; i < 3; i++) {
        keyPressRelease(KeyEvent.VK_TAB, 200);
        sleep(200);
    }

    // select populated target folder path
    keyPressReleaseControlA(500);

    // entering target folder path
    Keyboard keyboard = new Keyboard(robot);
    keyboard.type(castExtractionFile.getParent() + "\\deliveryResults");

    // navigate to options
    keyPressReleaseShiftTab(200);
    keyPressRelease(KeyEvent.VK_RIGHT, 500);
    for (int i = 0; i < 2; i++) {
        keyPressRelease(KeyEvent.VK_TAB, 200);
        sleep(200);
    }

    // select populated extraction file path
    keyPressReleaseControlA(500);

    // entering target folder path that contains .castextraction file
    keyboard.type(castExtractionFile.getPath());
    sleep(500);
    keyPressRelease(KeyEvent.VK_TAB, 200);
    sleep(500);

    // navigate to menu bar to select Application/Run Application since tabbing to 'Run Application' button
    // and pressing enter does not execute run
    keyPressRelease(KeyEvent.VK_ALT, 500);
    sleep(500);
    for (int i = 0; i < 2; i++) {
        keyPressRelease(KeyEvent.VK_RIGHT, 200);
    }
    keyPressRelease(KeyEvent.VK_ENTER, 200);
    keyPressRelease(KeyEvent.VK_DOWN, 500);
    keyPressRelease(KeyEvent.VK_ENTER, 200);

    sleep(5000);
    process.destroy();
}

From source file:com.rapidminer.gui.plotter.charts.ChartPanelShiftController.java

/**
 * Pan / Shifts a plot if the arrow keys are pressed.
 *//*from   ww w .jav  a2s.  com*/
public void keyPressed(KeyEvent e) {
    if (!plotSupported) {
        return;
    }

    int keyCode = e.getKeyCode();

    // we're only interested in arrows (code 37,38,39,40)
    if ((keyCode < 37) || (keyCode > 40)) {
        return;
    }

    // The axes we're gonna shift
    ValueAxis[] axes = null;

    boolean domainShift = false; // used for PAN_FIXED
    // Calculations for the domain axis
    if ((keyCode == KeyEvent.VK_LEFT) || (keyCode == KeyEvent.VK_RIGHT)) {
        axes = getPlotAxis(chartPanel.getChart(), !axesSwaped);
        domainShift = true;
    }
    // Calculations for the range axis
    else {
        axes = getPlotAxis(chartPanel.getChart(), axesSwaped);
    }

    // Delta is the amount we'll shift in axes units.
    double[] delta = new double[axes.length];

    // Let's calculate 'delta', the amount by which we'll shift the plot
    for (int i = 0; i < axes.length; i++) {
        switch (shiftType) {
        case SHIFT_PERCENTUAL:
            delta[i] = (axes[i].getUpperBound() - axes[i].getLowerBound()) / 100.0;
            break;
        case SHIFT_FIXED:
            delta[i] = (domainShift ? fixedDomainShiftUnits : fixedRangeShiftUnits);
            break;
        case SHIFT_PIXEL: // also the default
        default:
            // Let's find out what's the range for 1 pixel.
            final Rectangle2D scaledDataArea = chartPanel.getScreenDataArea();
            delta[i] = axes[i].getRange().getLength() / (scaledDataArea.getWidth());
            break;
        }
    }

    // Shift modifier multiplies delta by 10
    if (e.isShiftDown()) {
        for (int i = 0; i < delta.length; i++) {
            delta[i] *= 10;
        }
    }

    for (int i = 0; i < axes.length; i++) {
        switch (keyCode) {
        case KeyEvent.VK_LEFT:
        case KeyEvent.VK_DOWN:
            axes[i].setRange(axes[i].getLowerBound() - delta[i], axes[i].getUpperBound() - delta[i]);
            break;
        case KeyEvent.VK_UP:
        case KeyEvent.VK_RIGHT:
            axes[i].setRange(axes[i].getLowerBound() + delta[i], axes[i].getUpperBound() + delta[i]);
            break;
        }
    }
}

From source file:CopyAreaPerformance.java

/**
 * Arrow keys scroll the view around. The 'c' key toggles clip area
 * optimization. The 'a' key toggles copyArea optimization.
 *///from   ww  w.  ja v  a2 s . com
public void keyPressed(KeyEvent e) {
    if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
        scroll(SCROLL_SIZE, 0);
    } else if (e.getKeyCode() == KeyEvent.VK_LEFT) {
        scroll(-SCROLL_SIZE, 0);
    } else if (e.getKeyCode() == KeyEvent.VK_UP) {
        scroll(0, -SCROLL_SIZE);
    } else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
        scroll(0, SCROLL_SIZE);
    } else if (e.getKeyCode() == KeyEvent.VK_C) {
        useClip = !useClip;
        System.out.println("useClip = " + useClip);
    } else if (e.getKeyCode() == KeyEvent.VK_A) {
        useCopyArea = !useCopyArea;
        prevVX = -10000;
        System.out.println("useCopyArea = " + useCopyArea);
    }
}