Example usage for java.awt.event KeyEvent VK_MINUS

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

Introduction

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

Prototype

int VK_MINUS

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

Click Source Link

Document

Constant for the minus key, "-"

Usage

From source file:com.chaosting.product.hotkey.Main.java

/**
 * case ascii in (33,34,35,36,37,38,40...)shiftkeycode,keyperss(shift)keyrelease(shift)
 * /*w w  w.j  a v  a  2 s .  c  o m*/
 * String temp = "!@#$%^&()_+{}|:\"<>?";
 * String temp = "*-=[]\\;',./";
 * 
 * @param ascii
 * @return
 */
private int convertAsciiInt2KeycodeInt(int ascii) {
    if (ascii >= 65 && ascii <= 90) {
        return ascii;
    }
    if (ascii >= 48 && ascii <= 57) {
        return ascii + 48;
    }
    if (ascii >= 97 && ascii <= 122) {
        return ascii - 32;
    }
    switch (ascii) {
    case 13:
        return KeyEvent.VK_ENTER;

    case 32:
        return KeyEvent.VK_SPACE;
    //case 33:
    //   return KeyEvent.VK_EXCLAMATION_MARK;
    //case 34:
    //   return KeyEvent.VK_QUOTEDBL;
    //case 35:
    //   return KeyEvent.VK_NUMBER_SIGN;
    //case 36:
    //   return KeyEvent.VK_DOLLAR;
    // 37 %
    // 38 &
    case 39:
        return KeyEvent.VK_QUOTE;
    //case 40:
    //   return KeyEvent.VK_LEFT_PARENTHESIS;
    //case 41:
    //   return KeyEvent.VK_RIGHT_PARENTHESIS;
    case 42:
        return KeyEvent.VK_MULTIPLY;
    //case 43:
    //   return KeyEvent.VK_PLUS;
    case 44:
        return KeyEvent.VK_COMMA;
    case 45:
        return KeyEvent.VK_MINUS;
    case 46:
        return KeyEvent.VK_PERIOD;
    case 47:
        return KeyEvent.VK_SLASH;

    //case 58:
    //   return KeyEvent.VK_COLON;
    case 59:
        return KeyEvent.VK_SEMICOLON;
    //case 60:
    //   return KeyEvent.VK_LESS;
    case 61:
        return KeyEvent.VK_EQUALS;
    //case 62:
    //   return KeyEvent.VK_GREATER;
    // 63 ?   
    //case 64:
    //   return KeyEvent.VK_AT;

    case 91:
        return KeyEvent.VK_OPEN_BRACKET;
    case 92:
        return KeyEvent.VK_BACK_SLASH;
    case 93:
        return KeyEvent.VK_CLOSE_BRACKET;
    //case 94:
    //   return KeyEvent.VK_CIRCUMFLEX;
    //case 95:
    //   return KeyEvent.VK_UNDERSCORE;
    // 96 `
    //case 123:
    //   return KeyEvent.VK_BRACELEFT;
    // 124 |   
    //case 125:
    //   return KeyEvent.VK_BRACERIGHT;
    // 126 ~   
    default:
        return -1;
    }
}

From source file:edu.harvard.mcz.imagecapture.ImageZoomPanel.java

/**
 * This method initializes jButton1   /*from   ww  w .j av a2 s .  c  om*/
 *    
 * @return javax.swing.JButton   
 */
private JButton getJButton1() {
    if (jButton1 == null) {
        jButton1 = new JButton();
        jButton1.setText("Zoom Out -");
        jButton1.setMnemonic(KeyEvent.VK_MINUS);
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent e) {
                zoomOut();
            }
        });
    }
    return jButton1;
}

From source file:Main.java

public 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 w  ww  . j  a v a 2s.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";

    // 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: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  w w  w.  j  av a2  s.com
    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);
    }/*from  ww  w. j a  va  2 s . co  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";
    // 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:edu.purdue.cc.bionet.ui.CorrelationDisplayPanel.java

/**
 * Adds all of the necessary Components to this Component.
 *//*  w  w w  .  j  a  v  a  2 s. c om*/
private void buildPanel() {

    Language language = Settings.getLanguage();
    this.correlationMethodMenu = new JMenu(language.get("Correlation Method"));
    this.correlationMethodMenuButtonGroup = new ButtonGroup();
    this.pearsonCalculationMenuItem = new JRadioButtonMenuItem(language.get("Pearson"), true);
    this.spearmanCalculationMenuItem = new JRadioButtonMenuItem(language.get("Spearman"));
    this.kendallCalculationMenuItem = new JRadioButtonMenuItem(language.get("Kendall"));

    // layout menu itmes
    this.layoutMenu = new JMenu(language.get("Layout"));
    this.layoutMenuButtonGroup = new ButtonGroup();
    this.multipleCirclesLayoutMenuItem = new JRadioButtonMenuItem(language.get("Multiple Circles"));
    this.singleCircleLayoutMenuItem = new JRadioButtonMenuItem(language.get("Single Circle"), true);
    this.randomLayoutMenuItem = new JRadioButtonMenuItem(language.get("Random"));
    this.heatMapLayoutMenuItem = new JRadioButtonMenuItem(language.get("Heat Map"));
    this.kkLayoutMenuItem = new JRadioButtonMenuItem(language.get("Kamada-Kawai"));
    //      this.frLayoutMenuItem = 
    //            new JRadioButtonMenuItem( language.get( "Fruchterman-Reingold" ));
    //      this.springLayoutMenuItem = 
    //               new JRadioButtonMenuItem( language.get( "Spring Layout" ));
    this.frSpringLayoutMenuItem = new JRadioButtonMenuItem(language.get("Spring Layout"));
    //      this.animatedLayoutMenuItem = new JCheckBoxMenuItem( 
    //         language.get( "Fruchterman-Reingold Spring Embedding" ));

    // view menu items
    this.viewMenu = new JMenu(language.get("View"));
    this.zoomInViewMenuItem = new JMenuItem(language.get("Zoom In"), KeyEvent.VK_I);
    this.zoomOutViewMenuItem = new JMenuItem(language.get("Zoom Out"), KeyEvent.VK_O);
    this.fitToWindowViewMenuItem = new JMenuItem(language.get("Fit to Window"), KeyEvent.VK_F);
    this.selectAllViewMenuItem = new JMenuItem(language.get("Select All"), KeyEvent.VK_A);
    this.clearSelectionViewMenuItem = new JMenuItem(language.get("Clear Selection"), KeyEvent.VK_C);
    this.invertSelectionViewMenuItem = new JMenuItem(language.get("Invert Selection"), KeyEvent.VK_I);
    this.selectCorrelatedViewMenuItem = new JMenuItem(language.get("Select Correlated to Selection"),
            KeyEvent.VK_R);
    this.hideSelectedViewMenuItem = new JMenuItem(language.get("Hide Selected"), KeyEvent.VK_H);
    this.hideUnselectedViewMenuItem = new JMenuItem(language.get("Hide Unselected"), KeyEvent.VK_U);
    this.hideUncorrelatedViewMenuItem = new JMenuItem(language.get("Hide Uncorrelated to Selection"),
            KeyEvent.VK_L);
    this.hideOrphansViewMenuItem = new JMenuItem(language.get("Hide Orphans"), KeyEvent.VK_P);
    this.showCorrelatedViewMenuItem = new JMenuItem(language.get("Show All Correlated to Visible"),
            KeyEvent.VK_S);
    this.saveImageAction = new SaveImageAction(language.get("Save Main Graph Image") + "...", null);

    // groups menu items
    this.groupsMenu = new JMenu(language.get("Groups"));
    this.resetSampleGroupsMenuItem = new JMenuItem(language.get("Reset Sample Groups"), KeyEvent.VK_R);
    this.chooseSampleGroupsMenuItem = new JMenuItem(language.get("Choose Sample Groups") + "...",
            KeyEvent.VK_C);

    // color menu items
    this.colorMenu = new JMenu(language.get("Color"));
    this.colorMenuButtonGroup = new ButtonGroup();
    this.normalColorMenuItem = new JRadioButtonMenuItem(language.get("Normal Color"), true);
    this.highContrastColorMenuItem = new JRadioButtonMenuItem(language.get("High Contrast Color"));

    // CORRELATION FILTER ELEMENTS
    JPanel leftPanel = new JPanel(new BorderLayout());
    this.moleculeFilterPanel = new MoleculeFilterPanel();
    leftPanel.add(moleculeFilterPanel, BorderLayout.CENTER);
    this.correlationFilterPanel = new CorrelationFilterPanel();
    leftPanel.add(this.correlationFilterPanel, BorderLayout.SOUTH);

    //CALCULATION MENU
    this.correlationMethodMenu.setMnemonic(KeyEvent.VK_C);
    this.correlationMethodMenu.getAccessibleContext()
            .setAccessibleDescription(language.get("Perform Data Calculations"));
    this.correlationMethodMenuButtonGroup.add(this.pearsonCalculationMenuItem);
    this.correlationMethodMenuButtonGroup.add(this.spearmanCalculationMenuItem);
    this.correlationMethodMenuButtonGroup.add(this.kendallCalculationMenuItem);
    this.pearsonCalculationMenuItem.setMnemonic(KeyEvent.VK_P);
    this.spearmanCalculationMenuItem.setMnemonic(KeyEvent.VK_S);
    this.kendallCalculationMenuItem.setMnemonic(KeyEvent.VK_K);
    this.correlationMethodMenu.add(this.pearsonCalculationMenuItem);
    this.correlationMethodMenu.add(this.spearmanCalculationMenuItem);
    this.correlationMethodMenu.add(this.kendallCalculationMenuItem);
    this.pearsonCalculationMenuItem.addItemListener(this);
    this.spearmanCalculationMenuItem.addItemListener(this);
    this.kendallCalculationMenuItem.addItemListener(this);

    //LAYOUT MENU
    LayoutChangeListener lcl = new LayoutChangeListener();
    this.layoutMenu.setMnemonic(KeyEvent.VK_L);
    this.layoutMenu.getAccessibleContext()
            .setAccessibleDescription(language.get("Change the layout of the graph"));
    this.layoutMenuButtonGroup.add(this.multipleCirclesLayoutMenuItem);
    this.layoutMenuButtonGroup.add(this.singleCircleLayoutMenuItem);
    this.layoutMenuButtonGroup.add(this.randomLayoutMenuItem);
    this.layoutMenuButtonGroup.add(this.kkLayoutMenuItem);
    //      this.layoutMenuButtonGroup.add( this.frLayoutMenuItem );
    //      this.layoutMenuButtonGroup.add( this.springLayoutMenuItem );
    this.layoutMenuButtonGroup.add(this.frSpringLayoutMenuItem);
    this.layoutMenuButtonGroup.add(this.heatMapLayoutMenuItem);

    Enumeration<AbstractButton> e = this.layoutMenuButtonGroup.getElements();
    this.layoutMenu.add(this.multipleCirclesLayoutMenuItem);
    this.layoutMenu.add(this.singleCircleLayoutMenuItem);
    this.layoutMenu.add(this.randomLayoutMenuItem);
    this.layoutMenu.add(this.kkLayoutMenuItem);
    //      this.layoutMenu.add( this.frLayoutMenuItem );
    //      this.layoutMenu.add( this.springLayoutMenuItem );
    this.layoutMenu.add(this.frSpringLayoutMenuItem);
    this.layoutMenu.add(this.heatMapLayoutMenuItem);
    //      this.layoutMenu.addSeparator( );
    //      this.layoutMenu.add( this.animatedLayoutMenuItem );
    this.multipleCirclesLayoutMenuItem.addActionListener(lcl);
    this.multipleCirclesLayoutMenuItem.setEnabled(false);
    this.singleCircleLayoutMenuItem.addActionListener(lcl);
    this.randomLayoutMenuItem.addActionListener(lcl);
    this.kkLayoutMenuItem.addActionListener(lcl);
    //      this.frLayoutMenuItem.addActionListener( lcl );
    this.frSpringLayoutMenuItem.addActionListener(lcl);
    this.heatMapLayoutMenuItem.addActionListener(lcl);
    //      this.animatedLayoutMenuItem.addActionListener( lcl );

    //VIEW MENU
    this.viewMenu.add(this.colorMenu);
    this.viewMenu.addSeparator();
    this.viewMenu.setMnemonic(KeyEvent.VK_V);
    this.viewMenu.getAccessibleContext()
            .setAccessibleDescription(language.get("Change the data view settings"));
    this.viewMenu.add(this.zoomOutViewMenuItem);
    this.viewMenu.add(this.zoomInViewMenuItem);
    this.viewMenu.add(this.fitToWindowViewMenuItem);
    this.viewMenu.addSeparator();
    this.viewMenu.add(this.selectAllViewMenuItem);
    this.viewMenu.add(this.clearSelectionViewMenuItem);
    this.viewMenu.add(this.invertSelectionViewMenuItem);
    this.viewMenu.add(this.selectCorrelatedViewMenuItem);
    this.viewMenu.addSeparator();
    this.viewMenu.add(this.hideSelectedViewMenuItem);
    this.viewMenu.add(this.hideUnselectedViewMenuItem);
    this.viewMenu.add(this.hideUncorrelatedViewMenuItem);
    this.viewMenu.add(this.hideOrphansViewMenuItem);
    this.viewMenu.add(this.showCorrelatedViewMenuItem);
    this.viewMenu.addSeparator();
    this.viewMenu.add(this.saveImageAction);
    this.resetSampleGroupsMenuItem.addActionListener(this);
    this.chooseSampleGroupsMenuItem.addActionListener(this);
    this.zoomOutViewMenuItem.addActionListener(this);
    this.zoomInViewMenuItem.addActionListener(this);
    this.fitToWindowViewMenuItem.addActionListener(this);
    this.selectAllViewMenuItem.addActionListener(this);
    this.clearSelectionViewMenuItem.addActionListener(this);
    this.invertSelectionViewMenuItem.addActionListener(this);
    this.selectCorrelatedViewMenuItem.addActionListener(this);
    this.hideSelectedViewMenuItem.addActionListener(this);
    this.hideUnselectedViewMenuItem.addActionListener(this);
    this.hideUncorrelatedViewMenuItem.addActionListener(this);
    this.hideOrphansViewMenuItem.addActionListener(this);
    this.showCorrelatedViewMenuItem.addActionListener(this);
    this.selectAllViewMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.CTRL_DOWN_MASK));
    this.clearSelectionViewMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0));

    // GROUPS MENU
    this.groupsMenu.setMnemonic(KeyEvent.VK_G);
    this.groupsMenu.add(this.resetSampleGroupsMenuItem);
    this.groupsMenu.add(this.chooseSampleGroupsMenuItem);

    this.zoomOutViewMenuItem
            .setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, InputEvent.CTRL_DOWN_MASK));
    this.zoomInViewMenuItem
            .setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_EQUALS, InputEvent.CTRL_DOWN_MASK));
    this.fitToWindowViewMenuItem
            .setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_0, InputEvent.CTRL_DOWN_MASK));
    this.hideSelectedViewMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0));

    //COLOR MENU
    this.colorMenu.setMnemonic(KeyEvent.VK_R);
    this.colorMenu.getAccessibleContext()
            .setAccessibleDescription(language.get("Change the color of the graph"));
    this.colorMenuButtonGroup.add(this.normalColorMenuItem);
    this.colorMenuButtonGroup.add(this.highContrastColorMenuItem);
    this.colorMenu.add(this.normalColorMenuItem);
    this.colorMenu.add(this.highContrastColorMenuItem);
    this.normalColorMenuItem.addItemListener(this);
    this.highContrastColorMenuItem.addItemListener(this);

    this.menuBar.add(this.correlationMethodMenu);
    this.menuBar.add(this.layoutMenu);
    this.menuBar.add(this.viewMenu);
    this.menuBar.add(this.groupsMenu);

    // Add the panels to the main panel
    this.add(menuBar, BorderLayout.NORTH);
    //      this.add( this.correlationViewPanel, BorderLayout.CENTER );
    this.add(leftPanel, BorderLayout.WEST);
}

From source file:com.net2plan.gui.tools.GUINetworkDesign.java

private void addAllKeyCombinationActions() {
    addKeyCombinationAction("Resets the tool", new AbstractAction() {
        @Override//from   w ww . j  a  v a 2s  .c  o m
        public void actionPerformed(ActionEvent e) {
            resetButton();
        }
    }, KeyStroke.getKeyStroke(KeyEvent.VK_R, InputEvent.CTRL_DOWN_MASK));

    addKeyCombinationAction("Outputs current design to console", new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            System.out.println(getDesign().toString());
        }
    }, KeyStroke.getKeyStroke(KeyEvent.VK_F11, InputEvent.CTRL_DOWN_MASK));

    /* FROM THE OFFLINE ALGORITHM EXECUTION */

    addKeyCombinationAction("Execute algorithm", new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            executionPane.doClickInExecutionButton();
        }
    }, KeyStroke.getKeyStroke(KeyEvent.VK_E, KeyEvent.CTRL_DOWN_MASK));

    /* From the TOPOLOGY PANEL */
    addKeyCombinationAction("Load design", new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            topologyPanel.loadDesign();
        }
    }, KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_DOWN_MASK));

    addKeyCombinationAction("Save design", new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            topologyPanel.saveDesign();
        }
    }, KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK));

    addKeyCombinationAction("Zoom in", new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (topologyPanel.getSize().getWidth() != 0 && topologyPanel.getSize().getHeight() != 0)
                topologyPanel.getCanvas().zoomIn();
        }
    }, KeyStroke.getKeyStroke(KeyEvent.VK_ADD, InputEvent.CTRL_DOWN_MASK),
            KeyStroke.getKeyStroke(KeyEvent.VK_PLUS, InputEvent.CTRL_DOWN_MASK));

    addKeyCombinationAction("Zoom out", new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (topologyPanel.getSize().getWidth() != 0 && topologyPanel.getSize().getHeight() != 0)
                topologyPanel.getCanvas().zoomOut();
        }
    }, KeyStroke.getKeyStroke(KeyEvent.VK_SUBTRACT, InputEvent.CTRL_DOWN_MASK),
            KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, InputEvent.CTRL_DOWN_MASK));

    addKeyCombinationAction("Zoom all", new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (topologyPanel.getSize().getWidth() != 0 && topologyPanel.getSize().getHeight() != 0)
                topologyPanel.getCanvas().zoomAll();
        }
    }, KeyStroke.getKeyStroke(KeyEvent.VK_MULTIPLY, InputEvent.CTRL_DOWN_MASK));

    addKeyCombinationAction("Take snapshot", new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            topologyPanel.takeSnapshot();
        }
    }, KeyStroke.getKeyStroke(KeyEvent.VK_F12, InputEvent.CTRL_DOWN_MASK));

    addKeyCombinationAction("Load traffic demands", new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            topologyPanel.loadTrafficDemands();
        }
    }, KeyStroke.getKeyStroke(KeyEvent.VK_T, InputEvent.CTRL_DOWN_MASK));

    /* FROM REPORT */
    addKeyCombinationAction("Close selected report", new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            int tab = reportPane.getReportContainer().getSelectedIndex();
            if (tab == -1)
                return;
            reportPane.getReportContainer().remove(tab);
        }
    }, KeyStroke.getKeyStroke(KeyEvent.VK_W, InputEvent.CTRL_DOWN_MASK));

    addKeyCombinationAction("Close all reports", new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            reportPane.getReportContainer().removeAll();
        }
    }, KeyStroke.getKeyStroke(KeyEvent.VK_W, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK));

    /* Online simulation */
    addKeyCombinationAction("Run simulation", new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                if (onlineSimulationPane.isRunButtonEnabled())
                    onlineSimulationPane.runSimulation(false);
            } catch (Net2PlanException ex) {
                if (ErrorHandling.isDebugEnabled())
                    ErrorHandling.addErrorOrException(ex, OnlineSimulationPane.class);
                ErrorHandling.showErrorDialog(ex.getMessage(), "Error executing simulation");
            } catch (Throwable ex) {
                ErrorHandling.addErrorOrException(ex, OnlineSimulationPane.class);
                ErrorHandling.showErrorDialog("An error happened");
            }

        }
    }, KeyStroke.getKeyStroke(KeyEvent.VK_U, InputEvent.CTRL_DOWN_MASK));

    // Windows
    addKeyCombinationAction("Show control window", new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            WindowController.showTablesWindow(true);
        }
    }, KeyStroke.getKeyStroke(KeyEvent.VK_1, ActionEvent.ALT_MASK + ActionEvent.SHIFT_MASK));

    viewEditTopTables.setInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW,
            this.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW));
    viewEditTopTables.setActionMap(this.getActionMap());

    reportPane.setInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW,
            this.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW));
    reportPane.setActionMap(this.getActionMap());

    executionPane.setInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW,
            this.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW));
    executionPane.setActionMap(this.getActionMap());

    onlineSimulationPane.setInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW,
            this.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW));
    onlineSimulationPane.setActionMap(this.getActionMap());

    whatIfAnalysisPane.setInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW,
            this.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW));
    whatIfAnalysisPane.setActionMap(this.getActionMap());
}

From source file:GUI.MainWindow.java

/**
 * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor./*from w w  w  .  j a v a  2  s  .  c o m*/
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    ImportScanScreen = new javax.swing.JDialog();
    jLabel1 = new javax.swing.JLabel();
    jScrollPane2 = new javax.swing.JScrollPane();
    ImportFile = new javax.swing.JList();
    jLabel2 = new javax.swing.JLabel();
    FileType = new javax.swing.JTextField();
    jLabel3 = new javax.swing.JLabel();
    FileSize = new javax.swing.JTextField();
    ProgressBar = new javax.swing.JProgressBar();
    VulnTreeContextMenu = new javax.swing.JPopupMenu();
    MergeButton = new javax.swing.JMenuItem();
    LookupCVE = new javax.swing.JMenuItem();
    AddToPersonalVulns = new javax.swing.JMenuItem();
    ClearHash = new javax.swing.JMenuItem();
    jSeparator1 = new javax.swing.JPopupMenu.Separator();
    DeleteButton = new javax.swing.JMenuItem();
    VulnAffectedHostsContextMenu = new javax.swing.JPopupMenu();
    AddHostsButton = new javax.swing.JMenuItem();
    EditHostname = new javax.swing.JMenuItem();
    jSeparator2 = new javax.swing.JPopupMenu.Separator();
    DeleteHost = new javax.swing.JMenuItem();
    VulnReferencesContextMenu = new javax.swing.JPopupMenu();
    InsertReference = new javax.swing.JMenuItem();
    EditReferenceOption = new javax.swing.JMenuItem();
    LaunchInBrowser = new javax.swing.JMenuItem();
    jSeparator3 = new javax.swing.JPopupMenu.Separator();
    DeleteReferenceOption = new javax.swing.JMenuItem();
    ManageAffectedHosts = new javax.swing.JDialog();
    jScrollPane5 = new javax.swing.JScrollPane();
    ListOfHosts = new javax.swing.JList();
    jScrollPane9 = new javax.swing.JScrollPane();
    ListOfOpenPorts = new javax.swing.JList();
    jLabel5 = new javax.swing.JLabel();
    jLabel13 = new javax.swing.JLabel();
    MainScreenBottomPanel = new javax.swing.JPanel();
    jLabel20 = new javax.swing.JLabel();
    VulnTreeFilter = new javax.swing.JTextField();
    ExtraInfoLabel = new javax.swing.JLabel();
    jSplitPane2 = new javax.swing.JSplitPane();
    ViewModeTabPane = new javax.swing.JTabbedPane();
    jScrollPane1 = new javax.swing.JScrollPane();
    VulnTree = new javax.swing.JTree();
    jScrollPane3 = new javax.swing.JScrollPane();
    HostTree = new javax.swing.JTree();
    RightPanelCardLayout = new javax.swing.JPanel();
    RightPanelVulnView = new javax.swing.JPanel();
    VulnerabilityTopPanel = new javax.swing.JPanel();
    jPanel8 = new javax.swing.JPanel();
    jLabel9 = new javax.swing.JLabel();
    VulnTitleTextField = new javax.swing.JTextField();
    jPanel9 = new javax.swing.JPanel();
    jLabel10 = new javax.swing.JLabel();
    VulnCVSSVectorTextField = new javax.swing.JTextField();
    jLabel11 = new javax.swing.JLabel();
    VulnRiskCategory = new javax.swing.JTextField();
    jLabel12 = new javax.swing.JLabel();
    VulnScore = new javax.swing.JTextField();
    EditRiskButton = new javax.swing.JButton();
    jSplitPane1 = new javax.swing.JSplitPane();
    jSplitPane3 = new javax.swing.JSplitPane();
    VulnRecommendationsPanel = new javax.swing.JPanel();
    jLabel8 = new javax.swing.JLabel();
    jScrollPane7 = new javax.swing.JScrollPane();
    VulnRecommendationTextPane = new javax.swing.JTextPane();
    jSplitPane4 = new javax.swing.JSplitPane();
    VulnReferencesPanel = new javax.swing.JPanel();
    jLabel4 = new javax.swing.JLabel();
    jLabel7 = new javax.swing.JLabel();
    jScrollPane6 = new javax.swing.JScrollPane();
    VulnReferencesList = new javax.swing.JList();
    jScrollPane4 = new javax.swing.JScrollPane();
    VulnAffectedHostsTable = new javax.swing.JTable();
    VulnDescriptionPanel = new javax.swing.JPanel();
    jLabel6 = new javax.swing.JLabel();
    jScrollPane8 = new javax.swing.JScrollPane();
    VulnDescriptionTextPane = new javax.swing.JTextPane();
    RightPanelHostsView = new javax.swing.JPanel();
    jMenuBar1 = new javax.swing.JMenuBar();
    jMenu1 = new javax.swing.JMenu();
    jMenuItem3 = new javax.swing.JMenuItem();
    jMenuItem4 = new javax.swing.JMenuItem();
    jMenuItem5 = new javax.swing.JMenuItem();
    jMenuItem11 = new javax.swing.JMenuItem();
    exitButton = new javax.swing.JMenuItem();
    jMenu2 = new javax.swing.JMenu();
    jMenuItem1 = new javax.swing.JMenuItem();
    jMenuItem2 = new javax.swing.JMenuItem();
    jMenuItem7 = new javax.swing.JMenuItem();
    jMenuItem10 = new javax.swing.JMenuItem();
    jMenu4 = new javax.swing.JMenu();
    jMenuItem9 = new javax.swing.JMenuItem();
    jMenu3 = new javax.swing.JMenu();
    jMenuItem8 = new javax.swing.JMenuItem();
    jMenu5 = new javax.swing.JMenu();
    increaseFont = new javax.swing.JMenuItem();
    decreaseFont = new javax.swing.JMenuItem();

    ImportScanScreen.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    ImportScanScreen.setTitle("Report Compiler - Import Scan Screen");
    ImportScanScreen.setMinimumSize(new java.awt.Dimension(382, 220));
    ImportScanScreen.setModal(true);
    ImportScanScreen.addWindowListener(new java.awt.event.WindowAdapter() {
        public void windowActivated(java.awt.event.WindowEvent evt) {
            ImportScanScreenWindowActivated(evt);
        }
    });

    jLabel1.setText("File Name:");

    ImportFile.setModel(new javax.swing.AbstractListModel() {
        String[] strings = { "One" };

        public int getSize() {
            return strings.length;
        }

        public Object getElementAt(int i) {
            return strings[i];
        }
    });
    ImportFile.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
    ImportFile.setEnabled(false);
    jScrollPane2.setViewportView(ImportFile);

    jLabel2.setText("File Type:");

    FileType.setEnabled(false);

    jLabel3.setText("File Size:");

    FileSize.setEnabled(false);

    ProgressBar.setIndeterminate(true);

    javax.swing.GroupLayout ImportScanScreenLayout = new javax.swing.GroupLayout(
            ImportScanScreen.getContentPane());
    ImportScanScreen.getContentPane().setLayout(ImportScanScreenLayout);
    ImportScanScreenLayout
            .setHorizontalGroup(
                    ImportScanScreenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(ImportScanScreenLayout.createSequentialGroup().addGap(10, 10, 10)
                                    .addGroup(ImportScanScreenLayout
                                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel1)
                                            .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                    330, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jLabel2)
                                            .addComponent(FileType, javax.swing.GroupLayout.PREFERRED_SIZE, 330,
                                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jLabel3)
                                            .addComponent(FileSize, javax.swing.GroupLayout.PREFERRED_SIZE, 330,
                                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(ProgressBar, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                    330, javax.swing.GroupLayout.PREFERRED_SIZE))));
    ImportScanScreenLayout.setVerticalGroup(ImportScanScreenLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(ImportScanScreenLayout.createSequentialGroup().addGap(10, 10, 10).addComponent(jLabel1)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 24,
                            javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel2)
                    .addGap(6, 6, 6)
                    .addComponent(FileType, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 0, 0).addComponent(jLabel3).addGap(6, 6, 6)
                    .addComponent(FileSize, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(10, 10, 10).addComponent(ProgressBar, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)));

    MergeButton.setText("Merge");
    MergeButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            MergeButtonActionPerformed(evt);
        }
    });
    VulnTreeContextMenu.add(MergeButton);

    LookupCVE.setText("Lookup CVE(s)");
    LookupCVE.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            LookupCVEActionPerformed(evt);
        }
    });
    VulnTreeContextMenu.add(LookupCVE);

    AddToPersonalVulns.setText("Add to Personal Vulns");
    AddToPersonalVulns.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            AddToPersonalVulnsActionPerformed(evt);
        }
    });
    VulnTreeContextMenu.add(AddToPersonalVulns);

    ClearHash.setText("Clear Hash(s)");
    ClearHash.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            ClearHashActionPerformed(evt);
        }
    });
    VulnTreeContextMenu.add(ClearHash);
    VulnTreeContextMenu.add(jSeparator1);

    DeleteButton.setText("Delete");
    DeleteButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            DeleteButtonActionPerformed(evt);
        }
    });
    VulnTreeContextMenu.add(DeleteButton);

    VulnAffectedHostsContextMenu.setMinimumSize(new java.awt.Dimension(20, 20));

    AddHostsButton.setText("Add Host");
    AddHostsButton.setActionCommand("AddHost");
    AddHostsButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            AddHostsButtonActionPerformed(evt);
        }
    });
    VulnAffectedHostsContextMenu.add(AddHostsButton);

    EditHostname.setText("Edit Hostname");
    EditHostname.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            EditHostnameActionPerformed(evt);
        }
    });
    VulnAffectedHostsContextMenu.add(EditHostname);
    VulnAffectedHostsContextMenu.add(jSeparator2);

    DeleteHost.setText("Delete Host ('del' is hotkey)");
    DeleteHost.setActionCommand("DeleteHost");
    DeleteHost.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            DeleteHostActionPerformed(evt);
        }
    });
    VulnAffectedHostsContextMenu.add(DeleteHost);

    InsertReference.setText("Insert Reference");
    InsertReference.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            InsertReferenceActionPerformed(evt);
        }
    });
    VulnReferencesContextMenu.add(InsertReference);

    EditReferenceOption.setText("Edit Reference");
    EditReferenceOption.setToolTipText("");
    EditReferenceOption.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            EditReferenceOptionActionPerformed(evt);
        }
    });
    VulnReferencesContextMenu.add(EditReferenceOption);

    LaunchInBrowser.setText("Launch in Browser");
    LaunchInBrowser.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            LaunchInBrowserActionPerformed(evt);
        }
    });
    VulnReferencesContextMenu.add(LaunchInBrowser);
    VulnReferencesContextMenu.add(jSeparator3);

    DeleteReferenceOption.setText("Delete Reference");
    DeleteReferenceOption.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            DeleteReferenceOptionActionPerformed(evt);
        }
    });
    VulnReferencesContextMenu.add(DeleteReferenceOption);

    ManageAffectedHosts.setTitle("Report Compiler - Manage Affected Hosts");
    ManageAffectedHosts.addWindowListener(new java.awt.event.WindowAdapter() {
        public void windowOpened(java.awt.event.WindowEvent evt) {
            ManageAffectedHostsWindowOpened(evt);
        }
    });

    jScrollPane5.setViewportView(ListOfHosts);

    jScrollPane9.setViewportView(ListOfOpenPorts);

    jLabel5.setText("Hosts");

    jLabel13.setText("Ports");

    javax.swing.GroupLayout ManageAffectedHostsLayout = new javax.swing.GroupLayout(
            ManageAffectedHosts.getContentPane());
    ManageAffectedHosts.getContentPane().setLayout(ManageAffectedHostsLayout);
    ManageAffectedHostsLayout.setHorizontalGroup(
            ManageAffectedHostsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(ManageAffectedHostsLayout.createSequentialGroup().addGap(25, 25, 25)
                            .addGroup(ManageAffectedHostsLayout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 180,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel5))
                            .addGap(18, 18, 18)
                            .addGroup(ManageAffectedHostsLayout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel13).addComponent(jScrollPane9,
                                            javax.swing.GroupLayout.PREFERRED_SIZE, 213,
                                            javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
    ManageAffectedHostsLayout.setVerticalGroup(
            ManageAffectedHostsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(ManageAffectedHostsLayout.createSequentialGroup().addContainerGap()
                            .addGroup(ManageAffectedHostsLayout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel5).addComponent(jLabel13))
                            .addGap(13, 13, 13)
                            .addGroup(ManageAffectedHostsLayout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 291,
                                            Short.MAX_VALUE)
                                    .addComponent(jScrollPane9))
                            .addContainerGap(36, Short.MAX_VALUE)));

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setTitle("Report Compiler - Main Window");
    addWindowListener(new java.awt.event.WindowAdapter() {
        public void windowClosing(java.awt.event.WindowEvent evt) {
            formWindowClosing(evt);
        }
    });

    jLabel20.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
    jLabel20.setText("Tree Filter:");

    VulnTreeFilter.addCaretListener(new javax.swing.event.CaretListener() {
        public void caretUpdate(javax.swing.event.CaretEvent evt) {
            VulnTreeFilterCaretUpdate(evt);
        }
    });

    ExtraInfoLabel.setFont(
            ExtraInfoLabel.getFont().deriveFont(ExtraInfoLabel.getFont().getStyle() | java.awt.Font.BOLD));
    ExtraInfoLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);

    javax.swing.GroupLayout MainScreenBottomPanelLayout = new javax.swing.GroupLayout(MainScreenBottomPanel);
    MainScreenBottomPanel.setLayout(MainScreenBottomPanelLayout);
    MainScreenBottomPanelLayout.setHorizontalGroup(MainScreenBottomPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(MainScreenBottomPanelLayout.createSequentialGroup().addContainerGap()
                    .addComponent(jLabel20)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addComponent(VulnTreeFilter, javax.swing.GroupLayout.PREFERRED_SIZE, 174,
                            javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 354, Short.MAX_VALUE)
                    .addComponent(ExtraInfoLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 556,
                            javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap()));
    MainScreenBottomPanelLayout.setVerticalGroup(MainScreenBottomPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(MainScreenBottomPanelLayout.createSequentialGroup().addContainerGap()
                    .addGroup(MainScreenBottomPanelLayout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addGroup(MainScreenBottomPanelLayout.createSequentialGroup()
                                    .addComponent(ExtraInfoLabel, javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addGap(20, 20, 20))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING,
                                    MainScreenBottomPanelLayout
                                            .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                            .addComponent(jLabel20).addComponent(VulnTreeFilter,
                                                    javax.swing.GroupLayout.PREFERRED_SIZE,
                                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                                    javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

    getContentPane().add(MainScreenBottomPanel, java.awt.BorderLayout.SOUTH);

    jSplitPane2.setDividerLocation(200);
    jSplitPane2.setDividerSize(20);
    jSplitPane2.setOneTouchExpandable(true);

    ViewModeTabPane.addChangeListener(new javax.swing.event.ChangeListener() {
        public void stateChanged(javax.swing.event.ChangeEvent evt) {
            ViewModeTabPaneStateChanged(evt);
        }
    });

    javax.swing.tree.DefaultMutableTreeNode treeNode1 = new javax.swing.tree.DefaultMutableTreeNode(
            "NOT IMPLEMENTED");
    VulnTree.setModel(new javax.swing.tree.DefaultTreeModel(treeNode1));
    VulnTree.setCellRenderer(new VulnerabilityViewTreeCellRenderer(true));
    VulnTree.setRootVisible(false);
    VulnTree.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            VulnTreeMouseClicked(evt);
        }
    });
    VulnTree.addTreeSelectionListener(new javax.swing.event.TreeSelectionListener() {
        public void valueChanged(javax.swing.event.TreeSelectionEvent evt) {
            VulnTreeValueChanged(evt);
        }
    });
    VulnTree.addKeyListener(new java.awt.event.KeyAdapter() {
        public void keyPressed(java.awt.event.KeyEvent evt) {
            VulnTreeKeyPressed(evt);
        }
    });
    jScrollPane1.setViewportView(VulnTree);

    ViewModeTabPane.addTab("Vuln View", jScrollPane1);

    jScrollPane3.setEnabled(false);

    treeNode1 = new javax.swing.tree.DefaultMutableTreeNode("root");
    HostTree.setModel(new javax.swing.tree.DefaultTreeModel(treeNode1));
    HostTree.setRootVisible(false);
    jScrollPane3.setViewportView(HostTree);

    ViewModeTabPane.addTab("Host View", jScrollPane3);

    jSplitPane2.setLeftComponent(ViewModeTabPane);

    RightPanelCardLayout.setLayout(new java.awt.CardLayout());

    RightPanelVulnView.setLayout(new java.awt.BorderLayout());

    VulnerabilityTopPanel.setLayout(new java.awt.BorderLayout());

    jPanel8.setLayout(new javax.swing.BoxLayout(jPanel8, javax.swing.BoxLayout.LINE_AXIS));

    jLabel9.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
    jLabel9.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
    jLabel9.setLabelFor(VulnTitleTextField);
    jLabel9.setText("Title: ");
    jPanel8.add(jLabel9);

    VulnTitleTextField.setColumns(80);
    jPanel8.add(VulnTitleTextField);

    VulnerabilityTopPanel.add(jPanel8, java.awt.BorderLayout.NORTH);

    jPanel9.setLayout(new javax.swing.BoxLayout(jPanel9, javax.swing.BoxLayout.LINE_AXIS));

    jLabel10.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
    jLabel10.setText("CVSS:");
    jPanel9.add(jLabel10);

    VulnCVSSVectorTextField.setEditable(false);
    VulnCVSSVectorTextField.setColumns(81);
    jPanel9.add(VulnCVSSVectorTextField);

    jLabel11.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
    jLabel11.setText("Category:");
    jPanel9.add(jLabel11);

    VulnRiskCategory.setEditable(false);
    VulnRiskCategory.setColumns(8);
    jPanel9.add(VulnRiskCategory);

    jLabel12.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
    jLabel12.setText("Score:");
    jPanel9.add(jLabel12);

    VulnScore.setEditable(false);
    VulnScore.setColumns(4);
    jPanel9.add(VulnScore);

    EditRiskButton.setText("Edit Risk");
    EditRiskButton.setToolTipText("Click here to see the Risk Calculator where scores can be modified");
    EditRiskButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            EditRiskButtonActionPerformed(evt);
        }
    });
    jPanel9.add(EditRiskButton);

    VulnerabilityTopPanel.add(jPanel9, java.awt.BorderLayout.CENTER);

    RightPanelVulnView.add(VulnerabilityTopPanel, java.awt.BorderLayout.NORTH);

    jSplitPane1.setDividerLocation(200);
    jSplitPane1.setDividerSize(20);
    jSplitPane1.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
    jSplitPane1.setOneTouchExpandable(true);

    jSplitPane3.setDividerLocation(200);
    jSplitPane3.setDividerSize(20);
    jSplitPane3.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
    jSplitPane3.setOneTouchExpandable(true);

    VulnRecommendationsPanel.setLayout(new java.awt.BorderLayout());

    jLabel8.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
    jLabel8.setText("Recommendation");
    VulnRecommendationsPanel.add(jLabel8, java.awt.BorderLayout.PAGE_START);

    jScrollPane7.setViewportView(VulnRecommendationTextPane);

    VulnRecommendationsPanel.add(jScrollPane7, java.awt.BorderLayout.CENTER);

    jSplitPane3.setLeftComponent(VulnRecommendationsPanel);

    jSplitPane4.setDividerSize(20);
    jSplitPane4.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
    jSplitPane4.setOneTouchExpandable(true);

    VulnReferencesPanel.setLayout(new java.awt.BorderLayout());

    jLabel4.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
    jLabel4.setText("Affected Hosts");
    VulnReferencesPanel.add(jLabel4, java.awt.BorderLayout.PAGE_END);

    jLabel7.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
    jLabel7.setText("References");
    VulnReferencesPanel.add(jLabel7, java.awt.BorderLayout.PAGE_START);

    VulnReferencesList.setModel(new DefaultListModel());
    VulnReferencesList.setToolTipText("Right click on this area to see options for references.");
    VulnReferencesList.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            VulnReferencesListMouseClicked(evt);
        }
    });
    VulnReferencesList.addKeyListener(new java.awt.event.KeyAdapter() {
        public void keyPressed(java.awt.event.KeyEvent evt) {
            VulnReferencesListKeyPressed(evt);
        }
    });
    jScrollPane6.setViewportView(VulnReferencesList);

    VulnReferencesPanel.add(jScrollPane6, java.awt.BorderLayout.CENTER);

    jSplitPane4.setTopComponent(VulnReferencesPanel);

    jScrollPane4.setToolTipText(
            "Right click on this area to insert new affected hosts. Select one or more and press 'del' to delete or use the right click 'delete' option.");
    jScrollPane4.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            jScrollPane4MouseClicked(evt);
        }
    });
    jScrollPane4.addKeyListener(new java.awt.event.KeyAdapter() {
        public void keyPressed(java.awt.event.KeyEvent evt) {
            jScrollPane4KeyPressed(evt);
        }
    });

    VulnAffectedHostsTable.setAutoCreateRowSorter(true);
    VulnAffectedHostsTable.setModel(new AffectedHostsTableModel());

    /*new javax.swing.table.DefaultTableModel(
    new Object[][]{},
    new String[]{
        "IP Address", "Hostname", "Portnumber", "Protocol"
    }
    ) {
    Class[] types = new Class[]{
        Host.class, java.lang.String.class, java.lang.Integer.class, java.lang.String.class
    };
            
    public Class getColumnClass(int columnIndex) {
        return types[columnIndex];
    }
    }*///);
    VulnAffectedHostsTable.setToolTipText("");
    VulnAffectedHostsTable.setCellSelectionEnabled(true);
    VulnAffectedHostsTable.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            VulnAffectedHostsTableMouseClicked(evt);
        }
    });
    VulnAffectedHostsTable.addKeyListener(new java.awt.event.KeyAdapter() {
        public void keyPressed(java.awt.event.KeyEvent evt) {
            VulnAffectedHostsTableKeyPressed(evt);
        }
    });
    jScrollPane4.setViewportView(VulnAffectedHostsTable);
    VulnAffectedHostsTable.getColumnModel().getSelectionModel()
            .setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);

    jSplitPane4.setRightComponent(jScrollPane4);

    jSplitPane3.setRightComponent(jSplitPane4);

    jSplitPane1.setBottomComponent(jSplitPane3);

    VulnDescriptionPanel.setMinimumSize(new java.awt.Dimension(0, 50));
    VulnDescriptionPanel.setLayout(new java.awt.BorderLayout());

    jLabel6.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
    jLabel6.setText("Description");
    VulnDescriptionPanel.add(jLabel6, java.awt.BorderLayout.PAGE_START);

    jScrollPane8.setViewportView(VulnDescriptionTextPane);

    VulnDescriptionPanel.add(jScrollPane8, java.awt.BorderLayout.CENTER);

    jSplitPane1.setTopComponent(VulnDescriptionPanel);

    RightPanelVulnView.add(jSplitPane1, java.awt.BorderLayout.CENTER);

    RightPanelCardLayout.add(RightPanelVulnView, "vulnView");

    javax.swing.GroupLayout RightPanelHostsViewLayout = new javax.swing.GroupLayout(RightPanelHostsView);
    RightPanelHostsView.setLayout(RightPanelHostsViewLayout);
    RightPanelHostsViewLayout.setHorizontalGroup(RightPanelHostsViewLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 1103, Short.MAX_VALUE));
    RightPanelHostsViewLayout.setVerticalGroup(RightPanelHostsViewLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 739, Short.MAX_VALUE));

    RightPanelCardLayout.add(RightPanelHostsView, "hostView");

    jSplitPane2.setRightComponent(RightPanelCardLayout);

    getContentPane().add(jSplitPane2, java.awt.BorderLayout.CENTER);

    jMenu1.setMnemonic('F');
    jMenu1.setText("File");

    jMenuItem3.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N,
            java.awt.event.InputEvent.CTRL_MASK));
    jMenuItem3.setText("New (Clear Tree)");
    jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem3ActionPerformed(evt);
        }
    });
    jMenu1.add(jMenuItem3);

    jMenuItem4.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O,
            java.awt.event.InputEvent.CTRL_MASK));
    jMenuItem4.setText("Open");
    jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem4ActionPerformed(evt);
        }
    });
    jMenu1.add(jMenuItem4);

    jMenuItem5.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
            java.awt.event.InputEvent.CTRL_MASK));
    jMenuItem5.setText("Save");
    jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem5ActionPerformed(evt);
        }
    });
    jMenu1.add(jMenuItem5);

    jMenuItem11.setText("Save As");
    jMenuItem11.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem11ActionPerformed(evt);
        }
    });
    jMenu1.add(jMenuItem11);

    exitButton.setText("Exit");
    exitButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            exitButtonActionPerformed(evt);
        }
    });
    jMenu1.add(exitButton);

    jMenuBar1.add(jMenu1);

    jMenu2.setMnemonic('V');
    jMenu2.setText("Vulnerabilities");
    jMenu2.setToolTipText(
            "All vulnerability related operations. Import from a tool, create an entirely new one etc");

    jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_I,
            java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
    jMenuItem1.setText("Import from Tool");
    jMenuItem1.setToolTipText("Select one or more files to import simultaneously. ");
    jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem1ActionPerformed(evt);
        }
    });
    jMenu2.add(jMenuItem1);

    jMenuItem2.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_INSERT,
            java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
    jMenuItem2.setText("Create New Vulnerability");
    jMenuItem2.setToolTipText(
            "Add a new vulnerability to your test. When finished you can save it to your Personal Vulnerability database by right clicking on the issue in the tree");
    jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem2ActionPerformed(evt);
        }
    });
    jMenu2.add(jMenuItem2);

    jMenuItem7.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_M,
            java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
    jMenuItem7.setText("Manage Personal Vulns");
    jMenuItem7.setToolTipText(
            "Allows you to delete or edit the text for vulnerabilities in your Personal Database");
    jMenuItem7.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem7ActionPerformed(evt);
        }
    });
    jMenu2.add(jMenuItem7);

    jMenuItem10.setText("Auto Merge");
    jMenuItem10.setToolTipText(
            "Use this to automatically replace the title, description, recommendation, references, and risk score with vulnerabilities in your personal database.");
    jMenuItem10.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem10ActionPerformed(evt);
        }
    });
    jMenu2.add(jMenuItem10);

    jMenuBar1.add(jMenu2);

    jMenu4.setText("Hosts");

    jMenuItem9.setText("Import Hosts by Nmap");
    jMenuItem9.setEnabled(false);
    jMenu4.add(jMenuItem9);

    jMenuBar1.add(jMenu4);

    jMenu3.setMnemonic('E');
    jMenu3.setText("Export");

    jMenuItem8.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_E,
            java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
    jMenuItem8.setText("Excel Vulnerability List");
    jMenuItem8.setToolTipText(
            "This can be used to send a high level debrief to clients in a spreadsheet format. Report Compiler also imports vulnerabilities back from these excel files if necessary.");
    jMenuItem8.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem8ActionPerformed(evt);
        }
    });
    jMenu3.add(jMenuItem8);

    jMenuBar1.add(jMenu3);

    jMenu5.setText("Options");

    increaseFont.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_EQUALS,
            java.awt.event.InputEvent.CTRL_MASK));
    increaseFont.setText("Increase Font");
    increaseFont.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            increaseFontActionPerformed(evt);
        }
    });
    jMenu5.add(increaseFont);

    decreaseFont.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_MINUS,
            java.awt.event.InputEvent.CTRL_MASK));
    decreaseFont.setText("Decrease Font");
    decreaseFont.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            decreaseFontActionPerformed(evt);
        }
    });
    jMenu5.add(decreaseFont);

    jMenuBar1.add(jMenu5);

    setJMenuBar(jMenuBar1);

    pack();
    setLocationRelativeTo(null);
}

From source file:org.forester.archaeopteryx.TreePanel.java

final private void keyPressedCalls(final KeyEvent e) {
    if (isOvOn() && (getMousePosition() != null) && (getMousePosition().getLocation() != null)) {
        if (inOvVirtualRectangle(getMousePosition().x, getMousePosition().y)) {
            if (!isInOvRect()) {
                setInOvRect(true);//from ww  w  .  jav a 2s.c om
            }
        } else if (isInOvRect()) {
            setInOvRect(false);
        }
    }
    if (e.getModifiersEx() == InputEvent.CTRL_DOWN_MASK) {
        if ((e.getKeyCode() == KeyEvent.VK_DELETE) || (e.getKeyCode() == KeyEvent.VK_HOME)
                || (e.getKeyCode() == KeyEvent.VK_F)) {
            getMainPanel().getTreeFontSet().mediumFonts();
            getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged(true);
        } else if ((e.getKeyCode() == KeyEvent.VK_SUBTRACT) || (e.getKeyCode() == KeyEvent.VK_MINUS)) {
            getMainPanel().getTreeFontSet().decreaseFontSize();
            getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged(true);
        } else if (plusPressed(e.getKeyCode())) {
            getMainPanel().getTreeFontSet().increaseFontSize();
            getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged(true);
        }
    } else {
        if ((e.getKeyCode() == KeyEvent.VK_DELETE) || (e.getKeyCode() == KeyEvent.VK_HOME)
                || (e.getKeyCode() == KeyEvent.VK_F)) {
            getControlPanel().showWhole();
        } else if ((e.getKeyCode() == KeyEvent.VK_UP) || (e.getKeyCode() == KeyEvent.VK_DOWN)
                || (e.getKeyCode() == KeyEvent.VK_LEFT) || (e.getKeyCode() == KeyEvent.VK_RIGHT)) {
            if (e.getModifiersEx() == InputEvent.SHIFT_DOWN_MASK) {
                if (e.getKeyCode() == KeyEvent.VK_UP) {
                    getMainPanel().getControlPanel().zoomInY(Constants.WHEEL_ZOOM_IN_FACTOR);
                    getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged(false);
                } else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
                    getMainPanel().getControlPanel().zoomOutY(Constants.WHEEL_ZOOM_OUT_FACTOR);
                    getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged(false);
                } else if (e.getKeyCode() == KeyEvent.VK_LEFT) {
                    getMainPanel().getControlPanel().zoomOutX(Constants.WHEEL_ZOOM_OUT_FACTOR,
                            Constants.WHEEL_ZOOM_OUT_X_CORRECTION_FACTOR);
                    getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged(false);
                } else if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
                    getMainPanel().getControlPanel().zoomInX(Constants.WHEEL_ZOOM_IN_FACTOR,
                            Constants.WHEEL_ZOOM_IN_FACTOR);
                    getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged(false);
                }
            } else {
                final int d = 80;
                int dx = 0;
                int dy = -d;
                if (e.getKeyCode() == KeyEvent.VK_DOWN) {
                    dy = d;
                } else if (e.getKeyCode() == KeyEvent.VK_LEFT) {
                    dx = -d;
                    dy = 0;
                } else if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
                    dx = d;
                    dy = 0;
                }
                final Point scroll_position = getMainPanel().getCurrentScrollPane().getViewport()
                        .getViewPosition();
                scroll_position.x = scroll_position.x + dx;
                scroll_position.y = scroll_position.y + dy;
                if (scroll_position.x <= 0) {
                    scroll_position.x = 0;
                } else {
                    final int max_x = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar()
                            .getMaximum()
                            - getMainPanel().getCurrentScrollPane().getHorizontalScrollBar().getVisibleAmount();
                    if (scroll_position.x >= max_x) {
                        scroll_position.x = max_x;
                    }
                }
                if (scroll_position.y <= 0) {
                    scroll_position.y = 0;
                } else {
                    final int max_y = getMainPanel().getCurrentScrollPane().getVerticalScrollBar().getMaximum()
                            - getMainPanel().getCurrentScrollPane().getVerticalScrollBar().getVisibleAmount();
                    if (scroll_position.y >= max_y) {
                        scroll_position.y = max_y;
                    }
                }
                repaint();
                getMainPanel().getCurrentScrollPane().getViewport().setViewPosition(scroll_position);
            }
        } else if ((e.getKeyCode() == KeyEvent.VK_SUBTRACT) || (e.getKeyCode() == KeyEvent.VK_MINUS)) {
            getMainPanel().getControlPanel().zoomOutY(Constants.WHEEL_ZOOM_OUT_FACTOR);
            getMainPanel().getControlPanel().zoomOutX(Constants.WHEEL_ZOOM_OUT_FACTOR,
                    Constants.WHEEL_ZOOM_OUT_X_CORRECTION_FACTOR);
            getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged(false);
        } else if (plusPressed(e.getKeyCode())) {
            getMainPanel().getControlPanel().zoomInX(Constants.WHEEL_ZOOM_IN_FACTOR,
                    Constants.WHEEL_ZOOM_IN_FACTOR);
            getMainPanel().getControlPanel().zoomInY(Constants.WHEEL_ZOOM_IN_FACTOR);
            getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged(false);
        } else if (e.getKeyCode() == KeyEvent.VK_S) {
            if ((getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED)
                    || (getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR)) {
                setStartingAngle((getStartingAngle() % TWO_PI) + ANGLE_ROTATION_UNIT);
                getControlPanel().displayedPhylogenyMightHaveChanged(false);
            }
        } else if (e.getKeyCode() == KeyEvent.VK_A) {
            if ((getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED)
                    || (getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR)) {
                setStartingAngle((getStartingAngle() % TWO_PI) - ANGLE_ROTATION_UNIT);
                if (getStartingAngle() < 0) {
                    setStartingAngle(TWO_PI + getStartingAngle());
                }
                getControlPanel().displayedPhylogenyMightHaveChanged(false);
            }
        } else if (e.getKeyCode() == KeyEvent.VK_D) {
            boolean selected = false;
            if (getOptions().getNodeLabelDirection() == NODE_LABEL_DIRECTION.HORIZONTAL) {
                getOptions().setNodeLabelDirection(NODE_LABEL_DIRECTION.RADIAL);
                selected = true;
            } else {
                getOptions().setNodeLabelDirection(NODE_LABEL_DIRECTION.HORIZONTAL);
            }
            if (getMainPanel().getMainFrame() == null) {
                // Must be "E" applet version.
                final ArchaeopteryxE ae = (ArchaeopteryxE) ((MainPanelApplets) getMainPanel()).getApplet();
                if (ae.getlabelDirectionCbmi() != null) {
                    ae.getlabelDirectionCbmi().setSelected(selected);
                }
            } else {
                getMainPanel().getMainFrame().getlabelDirectionCbmi().setSelected(selected);
            }
            repaint();
        } else if (e.getKeyCode() == KeyEvent.VK_X) {
            switchDisplaygetPhylogenyGraphicsType();
            repaint();
        } else if (e.getKeyCode() == KeyEvent.VK_C) {
            cycleColors();
            repaint();
        } else if (getOptions().isShowOverview() && isOvOn() && (e.getKeyCode() == KeyEvent.VK_O)) {
            MainFrame.cycleOverview(getOptions(), this);
            repaint();
        } else if (getOptions().isShowOverview() && isOvOn() && (e.getKeyCode() == KeyEvent.VK_I)) {
            increaseOvSize();
        } else if (getOptions().isShowOverview() && isOvOn() && (e.getKeyCode() == KeyEvent.VK_U)) {
            decreaseOvSize();
        }
        e.consume();
    }
}

From source file:com.marginallyclever.makelangelo.MainGUI.java

public void updateMenuBar() {
    JMenu menu, subMenu;/*from w  w w  . jav a2 s  .c om*/
    ButtonGroup group;
    int i;

    if (settingsPane != null) {
        buttonAdjustMachineSize.setEnabled(!isrunning);
        buttonAdjustPulleySize.setEnabled(!isrunning);
        buttonJogMotors
                .setEnabled(connectionToRobot != null && connectionToRobot.isRobotConfirmed() && !isrunning);
        buttonChangeTool.setEnabled(!isrunning);
        buttonAdjustTool.setEnabled(!isrunning);
    }
    if (preparePane != null) {
        buttonHilbertCurve.setEnabled(!isrunning);
        buttonText2GCODE.setEnabled(!isrunning);
    }
    if (driveControls != null) {
        boolean x = connectionToRobot != null && connectionToRobot.isRobotConfirmed();
        driveControls.updateButtonAccess(x, isrunning);
    }

    menuBar.removeAll();

    // File menu
    menu = new JMenu(translator.get("MenuMakelangelo"));
    menu.setMnemonic(KeyEvent.VK_F);
    menuBar.add(menu);

    subMenu = new JMenu(translator.get("MenuPreferences"));

    buttonAdjustSounds = new JMenuItem(translator.get("MenuSoundsTitle"));
    buttonAdjustSounds.addActionListener(this);
    subMenu.add(buttonAdjustSounds);

    buttonAdjustGraphics = new JMenuItem(translator.get("MenuGraphicsTitle"));
    buttonAdjustGraphics.addActionListener(this);
    subMenu.add(buttonAdjustGraphics);

    buttonAdjustLanguage = new JMenuItem(translator.get("MenuLanguageTitle"));
    buttonAdjustLanguage.addActionListener(this);
    subMenu.add(buttonAdjustLanguage);
    menu.add(subMenu);

    buttonCheckForUpdate = new JMenuItem(translator.get("MenuUpdate"), KeyEvent.VK_U);
    buttonCheckForUpdate.addActionListener(this);
    buttonCheckForUpdate.setEnabled(true);
    menu.add(buttonCheckForUpdate);

    buttonAbout = new JMenuItem(translator.get("MenuAbout"), KeyEvent.VK_A);
    buttonAbout.addActionListener(this);
    menu.add(buttonAbout);

    menu.addSeparator();

    buttonExit = new JMenuItem(translator.get("MenuQuit"), KeyEvent.VK_Q);
    buttonExit.addActionListener(this);
    menu.add(buttonExit);

    // Connect menu
    subMenu = new JMenu(translator.get("MenuConnect"));
    subMenu.setEnabled(!isrunning);
    group = new ButtonGroup();

    String[] connections = connectionManager.listConnections();
    buttonPorts = new JRadioButtonMenuItem[connections.length];
    for (i = 0; i < connections.length; ++i) {
        buttonPorts[i] = new JRadioButtonMenuItem(connections[i]);
        if (connectionToRobot != null && connectionToRobot.getRecentConnection().equals(connections[i])
                && connectionToRobot.isConnectionOpen()) {
            buttonPorts[i].setSelected(true);
        }
        buttonPorts[i].addActionListener(this);
        group.add(buttonPorts[i]);
        subMenu.add(buttonPorts[i]);
    }

    subMenu.addSeparator();

    buttonRescan = new JMenuItem(translator.get("MenuRescan"), KeyEvent.VK_N);
    buttonRescan.addActionListener(this);
    subMenu.add(buttonRescan);

    buttonDisconnect = new JMenuItem(translator.get("MenuDisconnect"), KeyEvent.VK_D);
    buttonDisconnect.addActionListener(this);
    buttonDisconnect.setEnabled(connectionToRobot != null && connectionToRobot.isConnectionOpen());
    subMenu.add(buttonDisconnect);

    menuBar.add(subMenu);

    // view menu
    menu = new JMenu(translator.get("MenuPreview"));
    buttonZoomOut = new JMenuItem(translator.get("ZoomOut"));
    buttonZoomOut.addActionListener(this);
    buttonZoomOut.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, ActionEvent.ALT_MASK));
    menu.add(buttonZoomOut);

    buttonZoomIn = new JMenuItem(translator.get("ZoomIn"), KeyEvent.VK_EQUALS);
    buttonZoomIn.addActionListener(this);
    buttonZoomIn.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_EQUALS, ActionEvent.ALT_MASK));
    menu.add(buttonZoomIn);

    buttonZoomToFit = new JMenuItem(translator.get("ZoomFit"));
    buttonZoomToFit.addActionListener(this);
    menu.add(buttonZoomToFit);

    menuBar.add(menu);

    // finish
    menuBar.updateUI();
}