Example usage for java.awt.event KeyEvent VK_UP

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

Introduction

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

Prototype

int VK_UP

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

Click Source Link

Document

Constant for the non-numpad up arrow key.

Usage

From source file:ch.zhaw.iamp.rct.ui.GrammarWindow.java

private boolean isArrowKeyCode(int keyCode) {
    return keyCode == KeyEvent.VK_LEFT || keyCode == KeyEvent.VK_UP || keyCode == KeyEvent.VK_RIGHT
            || keyCode == KeyEvent.VK_DOWN;
}

From source file:org.yccheok.jstock.gui.charting.InvestmentFlowLayerUI.java

@Override
public void processKeyEvent(java.awt.event.KeyEvent e, JXLayer<? extends V> l) {
    if (e.getID() != KeyEvent.KEY_PRESSED) {
        // We are only interested in KEY_PRESSED event.
        return;//from  ww  w. j  av a2 s. com
    }
    final int code = e.getKeyCode();
    switch (code) {
    case KeyEvent.VK_LEFT:
        this.updatePointAndIndexIfPossible(-1);
        break;
    case KeyEvent.VK_RIGHT:
        this.updatePointAndIndexIfPossible(+1);
        break;
    case KeyEvent.VK_UP:
        // Switch to another stock.
        this.investmentFlowChartJDialog.selectPreviousJComboBoxSelection();
        break;
    case KeyEvent.VK_DOWN:
        // Switch to another stock.
        this.investmentFlowChartJDialog.selectNextJComboBoxSelection();
        break;
    }
}

From source file:com.sshtools.sshterm.emulation.TerminalEmulation.java

public void keyPressed(int keyCode, char keyChar, int modifiers) {
    if (debug > 0) {
        System.out.println("keyPressed(" + keyCode + "," + keyChar + "," + modifiers);
    }/*from w  ww.  ja va2 s.c  o m*/
    boolean control = (modifiers & VDUInput.KEY_CONTROL) != 0;
    boolean shift = (modifiers & VDUInput.KEY_SHIFT) != 0;
    boolean alt = (modifiers & VDUInput.KEY_ALT) != 0;
    int xind;
    String[] fmap;
    xind = 0;
    fmap = FunctionKey;
    if (shift) {
        fmap = FunctionKeyShift;
        xind = 1;
    }
    if (control) {
        fmap = FunctionKeyCtrl;
        xind = 2;
    }
    if (alt) {
        fmap = FunctionKeyAlt;
        xind = 3;
    }
    switch (keyCode) {
    case KeyEvent.VK_PAUSE:
        if (shift || control) {
            sendTelnetCommand((byte) 243);
        }

        // BREAK
        break;
    case KeyEvent.VK_ESCAPE:
        writeSpecial(Escape[xind]);
        break;
    case KeyEvent.VK_F1:
        writeSpecial(fmap[1]);
        break;
    case KeyEvent.VK_F2:
        writeSpecial(fmap[2]);
        break;
    case KeyEvent.VK_F3:
        writeSpecial(fmap[3]);
        break;
    case KeyEvent.VK_F4:
        writeSpecial(fmap[4]);
        break;
    case KeyEvent.VK_F5:
        writeSpecial(fmap[5]);
        break;
    case KeyEvent.VK_F6:
        writeSpecial(fmap[6]);
        break;
    case KeyEvent.VK_F7:
        writeSpecial(fmap[7]);
        break;
    case KeyEvent.VK_F8:
        writeSpecial(fmap[8]);
        break;
    case KeyEvent.VK_F9:
        writeSpecial(fmap[9]);
        break;
    case KeyEvent.VK_F10:
        writeSpecial(fmap[10]);
        break;
    case KeyEvent.VK_F11:
        writeSpecial(fmap[11]);
        break;
    case KeyEvent.VK_F12:
        writeSpecial(fmap[12]);
        break;
    case KeyEvent.VK_UP:
        writeSpecial(KeyUp[xind]);
        break;
    case KeyEvent.VK_DOWN:
        writeSpecial(KeyDown[xind]);
        break;
    case KeyEvent.VK_LEFT:
        writeSpecial(KeyLeft[xind]);
        break;
    case KeyEvent.VK_RIGHT:
        writeSpecial(KeyRight[xind]);
        break;
    case KeyEvent.VK_PAGE_DOWN:
        writeSpecial(NextScn[xind]);
        break;
    case KeyEvent.VK_PAGE_UP:
        writeSpecial(PrevScn[xind]);
        break;
    case KeyEvent.VK_INSERT:
        writeSpecial(Insert[xind]);
        break;
    case KeyEvent.VK_DELETE:
        writeSpecial(Remove[xind]);
        break;
    case KeyEvent.VK_BACK_SPACE:
        writeSpecial(BackSpace[xind]);
        if (localecho) {
            if (BackSpace[xind] == "\b" || BackSpace[xind] == "\u007f") {
                putString("\b \b");
                // make the last char 'deleted'
            } else {
                putString(BackSpace[xind]);
                // echo it
            }
        }
        break;
    case KeyEvent.VK_HOME:
        writeSpecial(KeyHome[xind]);
        break;
    case KeyEvent.VK_END:
        writeSpecial(KeyEnd[xind]);
        break;
    case KeyEvent.VK_NUM_LOCK:
        if (vms && control) {
            writeSpecial(PF1);
        }
        if (!control) {
            numlock = !numlock;
        }
        break;
    case KeyEvent.VK_CAPS_LOCK:
        capslock = !capslock;
        return;
    case KeyEvent.VK_SHIFT:
    case KeyEvent.VK_CONTROL:
    case KeyEvent.VK_ALT:
        return;
    default:
        break;
    }
}

From source file:Report_PRCR_New_EPF_Excel_File_Generator.java

private void monthfield1KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_monthfield1KeyPressed
    if (monthfield1.getText().equals("Jan")) {
        if (evt.getKeyCode() == KeyEvent.VK_DOWN) {
            monthfield1.setText("Dec");
            int yr = Integer.parseInt(yearfield.getText());

            yearfield1.setText("" + (yr - 1));
            monthfield1.selectAll();/*from   ww  w. j  a va 2 s  .co  m*/

        }
        if (evt.getKeyCode() == KeyEvent.VK_UP) {
            monthfield1.setText("Feb");
            monthfield1.selectAll();
        }

    } else if (monthfield1.getText().equals("Feb")) {
        if (evt.getKeyCode() == KeyEvent.VK_DOWN) {
            monthfield1.setText("Jan");
            int yr = Integer.parseInt(yearfield.getText());
            monthfield1.selectAll();

        }
        if (evt.getKeyCode() == KeyEvent.VK_UP) {
            monthfield1.setText("Mar");
            monthfield1.selectAll();
        }

    } else if (monthfield1.getText().equals("Mar")) {
        if (evt.getKeyCode() == KeyEvent.VK_DOWN) {
            monthfield1.setText("Feb");
            int yr = Integer.parseInt(yearfield1.getText());
            monthfield1.selectAll();
        }
        if (evt.getKeyCode() == KeyEvent.VK_UP) {
            monthfield1.setText("Apr");
            monthfield1.selectAll();
        }

    } else if (monthfield1.getText().equals("Apr")) {
        if (evt.getKeyCode() == KeyEvent.VK_DOWN) {
            monthfield1.setText("Mar");
            int yr = Integer.parseInt(yearfield1.getText());
            monthfield1.selectAll();
        }
        if (evt.getKeyCode() == KeyEvent.VK_UP) {
            monthfield1.setText("May");
            monthfield1.selectAll();
        }

    } else if (monthfield1.getText().equals("May")) {
        if (evt.getKeyCode() == KeyEvent.VK_DOWN) {
            monthfield1.setText("Apr");
            int yr = Integer.parseInt(yearfield1.getText());
            monthfield1.selectAll();

        }
        if (evt.getKeyCode() == KeyEvent.VK_UP) {

            monthfield1.setText("Jun");
            monthfield1.selectAll();
        }

    } else if (monthfield1.getText().equals("Jun")) {
        if (evt.getKeyCode() == KeyEvent.VK_DOWN) {
            monthfield1.setText("May");
            int yr = Integer.parseInt(yearfield1.getText());
            monthfield1.selectAll();

        }
        if (evt.getKeyCode() == KeyEvent.VK_UP) {
            monthfield1.setText("Jul");
            monthfield1.selectAll();
        }

    } else if (monthfield1.getText().equals("Jul")) {
        if (evt.getKeyCode() == KeyEvent.VK_DOWN) {
            monthfield1.setText("Jun");
            int yr = Integer.parseInt(yearfield1.getText());
            monthfield1.selectAll();

        }
        if (evt.getKeyCode() == KeyEvent.VK_UP) {
            monthfield1.setText("Aug");
            monthfield1.selectAll();
        }

    } else if (monthfield1.getText().equals("Aug")) {
        if (evt.getKeyCode() == KeyEvent.VK_DOWN) {
            monthfield1.setText("Jul");
            int yr = Integer.parseInt(yearfield1.getText());
            monthfield1.selectAll();

        }
        if (evt.getKeyCode() == KeyEvent.VK_UP) {
            monthfield1.setText("Sep");
            monthfield1.selectAll();
        }

    } else if (monthfield1.getText().equals("Sep")) {
        if (evt.getKeyCode() == KeyEvent.VK_DOWN) {
            monthfield1.setText("Aug");
            int yr = Integer.parseInt(yearfield1.getText());
            monthfield1.selectAll();

        }
        if (evt.getKeyCode() == KeyEvent.VK_UP) {
            monthfield1.setText("Oct");
            monthfield1.selectAll();
        }

    } else if (monthfield1.getText().equals("Oct")) {
        if (evt.getKeyCode() == KeyEvent.VK_DOWN) {
            monthfield1.setText("Sep");
            int yr = Integer.parseInt(yearfield1.getText());
            monthfield1.selectAll();

        }
        if (evt.getKeyCode() == KeyEvent.VK_UP) {
            monthfield1.setText("Nov");
            monthfield1.selectAll();
        }

    } else if (monthfield1.getText().equals("Nov")) {
        if (evt.getKeyCode() == KeyEvent.VK_DOWN) {
            monthfield1.setText("Oct");
            int yr = Integer.parseInt(yearfield1.getText());
            monthfield1.selectAll();

        }
        if (evt.getKeyCode() == KeyEvent.VK_UP) {
            monthfield1.setText("Dec");
            monthfield1.selectAll();
        }

    } else if (monthfield1.getText().equals("Dec")) {
        if (evt.getKeyCode() == KeyEvent.VK_DOWN) {
            monthfield1.setText("Nov");
            int yr = Integer.parseInt(yearfield1.getText());
            monthfield1.selectAll();

        }
        if (evt.getKeyCode() == KeyEvent.VK_UP) {
            monthfield1.setText("Jan");
            int yr = Integer.parseInt(yearfield1.getText());

            yearfield1.setText("" + (yr + 1));
            monthfield1.selectAll();
        }

    }
    if (evt.getKeyCode() == KeyEvent.VK_LEFT) {
        dayfield.requestFocus();
        dayfield.selectAll();
    }
    if (evt.getKeyCode() == KeyEvent.VK_RIGHT) {
        yearfield1.requestFocus();
        yearfield1.selectAll();
    }

    if (evt.getKeyCode() == KeyEvent.VK_ENTER) { ////// ChaNGE  focus on enter////////////////
        // recieptNo.requestFocus();

    }
}

From source file:dictionary.GUI.GUI_Main.java

private void fieldWordKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_fieldWordKeyPressed
    if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
        showMean();/*ww  w .j av a  2 s .c om*/
    }

    if (!onl && (evt.getKeyCode() == KeyEvent.VK_DOWN || evt.getKeyCode() == KeyEvent.VK_UP)) {
        listEntries.requestFocus();
    }

    if (evt.getKeyCode() == KeyEvent.VK_F1) {
        if (comboBoxEV.getSelectedIndex() == 0)
            voice.speechText(fieldWord.getText());
    }
}

From source file:Report_PRCR_New_EPF_Excel_File_Generator.java

private void yearfield1KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_yearfield1KeyPressed
    if (evt.getKeyCode() == KeyEvent.VK_UP) {
        yearfield.setText("" + (Integer.parseInt(yearfield.getText()) + 1));
        yearfield.selectAll();/* w  w w  .  ja  va  2 s . com*/
    }
    if (evt.getKeyCode() == KeyEvent.VK_DOWN) {
        yearfield.setText("" + (Integer.parseInt(yearfield.getText()) - 1));
        yearfield.selectAll();
    }
    if (evt.getKeyCode() == KeyEvent.VK_LEFT) {
        monthfield.requestFocus();
        monthfield.selectAll();
    }

    if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
    }
}

From source file:org.safs.selenium.webdriver.lib.WDLibrary.java

/**
 * Convert a Java KEYCODE to a Selenium WebDriver Keys Enum
 * @param keycode int, a java keycode//from   ww w. j  a  v a  2s  .com
 * @return Keys enum for (primarily) non-printable (control) characters, or null.
 */
public static Keys convertToKeys(int keycode) {
    Keys key = null;
    switch (keycode) {
    case java.awt.event.KeyEvent.VK_ADD:
        key = Keys.ADD;
        break;
    case java.awt.event.KeyEvent.VK_ALT:
        key = Keys.ALT;
        break;
    case java.awt.event.KeyEvent.VK_KP_DOWN:
        key = Keys.ARROW_DOWN;
        break;
    case java.awt.event.KeyEvent.VK_KP_LEFT:
        key = Keys.ARROW_LEFT;
        break;
    case java.awt.event.KeyEvent.VK_KP_RIGHT:
        key = Keys.ARROW_RIGHT;
        break;
    case java.awt.event.KeyEvent.VK_KP_UP:
        key = Keys.ARROW_UP;
        break;
    case java.awt.event.KeyEvent.VK_BACK_SPACE:
        key = Keys.BACK_SPACE;
        break;
    case java.awt.event.KeyEvent.VK_CANCEL:
        key = Keys.CANCEL;
        break;
    case java.awt.event.KeyEvent.VK_CLEAR:
        key = Keys.CLEAR;
        break;
    case java.awt.event.KeyEvent.VK_WINDOWS:
        key = Keys.COMMAND;
        break;
    case java.awt.event.KeyEvent.VK_CONTROL:
        key = Keys.CONTROL;
        break;
    case java.awt.event.KeyEvent.VK_DECIMAL:
        key = Keys.DECIMAL;
        break;
    case java.awt.event.KeyEvent.VK_DELETE:
        key = Keys.DELETE;
        break;
    case java.awt.event.KeyEvent.VK_DIVIDE:
        key = Keys.DIVIDE;
        break;
    case java.awt.event.KeyEvent.VK_DOWN:
        key = Keys.DOWN;
        break;
    case java.awt.event.KeyEvent.VK_END:
        key = Keys.END;
        break;
    case java.awt.event.KeyEvent.VK_ENTER:
        key = Keys.ENTER;
        break;
    case java.awt.event.KeyEvent.VK_EQUALS:
        key = Keys.EQUALS;
        break;
    case java.awt.event.KeyEvent.VK_ESCAPE:
        key = Keys.ESCAPE;
        break;
    case java.awt.event.KeyEvent.VK_F1:
        key = Keys.F1;
        break;
    case java.awt.event.KeyEvent.VK_F2:
        key = Keys.F2;
        break;
    case java.awt.event.KeyEvent.VK_F3:
        key = Keys.F3;
        break;
    case java.awt.event.KeyEvent.VK_F4:
        key = Keys.F4;
        break;
    case java.awt.event.KeyEvent.VK_F5:
        key = Keys.F5;
        break;
    case java.awt.event.KeyEvent.VK_F6:
        key = Keys.F6;
        break;
    case java.awt.event.KeyEvent.VK_F7:
        key = Keys.F7;
        break;
    case java.awt.event.KeyEvent.VK_F8:
        key = Keys.F8;
        break;
    case java.awt.event.KeyEvent.VK_F9:
        key = Keys.F9;
        break;
    case java.awt.event.KeyEvent.VK_F10:
        key = Keys.F10;
        break;
    case java.awt.event.KeyEvent.VK_F11:
        key = Keys.F11;
        break;
    case java.awt.event.KeyEvent.VK_F12:
        key = Keys.F12;
        break;
    case java.awt.event.KeyEvent.VK_HELP:
        key = Keys.HELP;
        break;
    case java.awt.event.KeyEvent.VK_HOME:
        key = Keys.HOME;
        break;
    case java.awt.event.KeyEvent.VK_INSERT:
        key = Keys.INSERT;
        break;
    case java.awt.event.KeyEvent.VK_LEFT:
        key = Keys.LEFT;
        break;
    case java.awt.event.KeyEvent.VK_META:
        key = Keys.META;
        break;
    case java.awt.event.KeyEvent.VK_MULTIPLY:
        key = Keys.MULTIPLY;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD0:
        key = Keys.NUMPAD0;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD1:
        key = Keys.NUMPAD1;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD2:
        key = Keys.NUMPAD2;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD3:
        key = Keys.NUMPAD3;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD4:
        key = Keys.NUMPAD4;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD5:
        key = Keys.NUMPAD5;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD6:
        key = Keys.NUMPAD6;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD7:
        key = Keys.NUMPAD7;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD8:
        key = Keys.NUMPAD8;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD9:
        key = Keys.NUMPAD9;
        break;
    case java.awt.event.KeyEvent.VK_PAGE_DOWN:
        key = Keys.PAGE_DOWN;
        break;
    case java.awt.event.KeyEvent.VK_PAGE_UP:
        key = Keys.PAGE_UP;
        break;
    case java.awt.event.KeyEvent.VK_PAUSE:
        key = Keys.PAUSE;
        break;
    case java.awt.event.KeyEvent.VK_RIGHT:
        key = Keys.RIGHT;
        break;
    case java.awt.event.KeyEvent.VK_SEMICOLON:
        key = Keys.SEMICOLON;
        break;
    case java.awt.event.KeyEvent.VK_SEPARATOR:
        key = Keys.SEPARATOR;
        break;
    case java.awt.event.KeyEvent.VK_SHIFT:
        key = Keys.SHIFT;
        break;
    case java.awt.event.KeyEvent.VK_SPACE:
        key = Keys.SPACE;
        break;
    case java.awt.event.KeyEvent.VK_SUBTRACT:
        key = Keys.SUBTRACT;
        break;
    case java.awt.event.KeyEvent.VK_TAB:
        key = Keys.TAB;
        break;
    case java.awt.event.KeyEvent.VK_UP:
        key = Keys.UP;
        break;
    }
    return key;
}

From source file:Report_PRCR_New_EPF_Excel_File_Generator.java

private void dayfieldKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_dayfieldKeyPressed
    ///////////////////////////////////////////////////  Days Decrement/////////////////////////////////////////////////////////////////////////////

    if (dayfield.getText().equals("1")) { // Jumping to 31 and 30 from 1st
        if (evt.getKeyCode() == KeyEvent.VK_DOWN) {

            if (monthfield.getText().equals("Feb") || monthfield.getText().equals("Apr")
                    || monthfield.getText().equals("Jun") || monthfield.getText().equals("Aug")
                    || monthfield.getText().equals("Sep") || monthfield.getText().equals("Nov")
                    || monthfield.getText().equals("Feb")) {
                dayfield.setText("31");

                int mnth = datechooser.return_index(monthfield.getText());
                monthfield.setText(datechooser.Return_month(mnth - 1));

            } else if (monthfield.getText().equals("May") || monthfield.getText().equals("Jul")
                    || monthfield.getText().equals("Oct") || monthfield.getText().equals("Dec")) {
                dayfield.setText("30");
                int mnth = datechooser.return_index(monthfield.getText());
                monthfield.setText(datechooser.Return_month(mnth - 1));

            } else if (monthfield.getText().equals("Mar")) { // from march 1st jump to 28th or 29th checking leap years
                int yr = Integer.parseInt(yearfield.getText());
                if (yr % 4 == 0) {
                    if (yr % 100 == 0) {
                        if (yr % 400 == 0) {
                            dayfield.setText("29"); // Leap Year
                        }/*from  w w  w  . ja va  2s .  c  o  m*/
                    }
                    if (yr % 100 == 0) {
                        if (yr % 400 != 0) {
                            dayfield.setText("28"); // not a leap year
                        }
                    }
                    dayfield.setText("29"); // leap year

                }
                if (yr % 4 != 0) {
                    dayfield.setText("28"); // not a leap year
                }
                int mnth = datechooser.return_index(monthfield.getText());
                monthfield.setText(datechooser.Return_month(mnth - 1));

            } else if (monthfield.getText().equals("Jan")) { // From jan 1st jump to december 31st decrementing year
                dayfield.setText("31");

                int yr = Integer.parseInt(yearfield.getText());
                monthfield.setText("Dec");
                yearfield.setText("" + (yr - 1)); // year
            }
            dayfield.selectAll();
        } // /// decrementing normal values
    } else if (dayfield.getText().equals("2") || dayfield.getText().equals("3")
            || dayfield.getText().equals("4") || dayfield.getText().equals("5")
            || dayfield.getText().equals("6") || dayfield.getText().equals("7")
            || dayfield.getText().equals("8") || dayfield.getText().equals("9")
            || dayfield.getText().equals("10") || dayfield.getText().equals("11")
            || dayfield.getText().equals("12") || dayfield.getText().equals("13")
            || dayfield.getText().equals("14") || dayfield.getText().equals("15")
            || dayfield.getText().equals("16") || dayfield.getText().equals("17")
            || dayfield.getText().equals("18") || dayfield.getText().equals("19")
            || dayfield.getText().equals("20") || dayfield.getText().equals("21")
            || dayfield.getText().equals("22") || dayfield.getText().equals("23")
            || dayfield.getText().equals("24") || dayfield.getText().equals("25")
            || dayfield.getText().equals("26") || dayfield.getText().equals("27")
            || dayfield.getText().equals("28") || dayfield.getText().equals("29")
            || dayfield.getText().equals("30") || dayfield.getText().equals("31")) {
        if (evt.getKeyCode() == KeyEvent.VK_DOWN) {

            dayfield.setText("" + (Integer.parseInt(dayfield.getText()) - 1));
            dayfield.selectAll();
        }
    }
    /////////////////////////////////////////////////  Days Increment///////////////////////////////////////////////////////////////////////////////////////////////////
    if (dayfield.getText().equals("30")) { // from 30th to 1st of next month
        if (evt.getKeyCode() == KeyEvent.VK_UP) {

            if (monthfield.getText().equals("Apr") || monthfield.getText().equals("Jun")
                    || monthfield.getText().equals("Sep") || monthfield.getText().equals("Nov")) {
                dayfield.setText("0");

                int mnth = datechooser.return_index(monthfield.getText());
                monthfield.setText(datechooser.Return_month(mnth + 1));

            }
            dayfield.setText("" + (Integer.parseInt(dayfield.getText()) + 1));
            dayfield.selectAll();
        }

    } else if (dayfield.getText().equals("31")) { // from 31st to 1st of next month
        if (evt.getKeyCode() == KeyEvent.VK_UP) {

            if (monthfield.getText().equals("Jan") || monthfield.getText().equals("Mar")
                    || monthfield.getText().equals("May") || monthfield.getText().equals("Jul")
                    || monthfield.getText().equals("Aug") || monthfield.getText().equals("Oct")) {
                dayfield.setText("1");

                int mnth = datechooser.return_index(monthfield.getText());
                monthfield.setText(datechooser.Return_month(mnth + 1));

            } else if (monthfield.getText().equals("Dec")) { // December to january incrementing the year

                dayfield.setText("1");

                int yr = Integer.parseInt(yearfield.getText());
                monthfield.setText("Jan");
                yearfield.setText("" + (yr + 1));
            }
            dayfield.selectAll();
        }

    } else if (monthfield.getText().equals("Feb")) { // for february
        if (evt.getKeyCode() == KeyEvent.VK_UP) {
            if (dayfield.getText().equals("28")) { // at 28 check for leap year
                int yr = Integer.parseInt(yearfield.getText());
                if (yr % 4 == 0) {
                    if (yr % 100 == 0) {
                        if (yr % 400 == 0) {
                            dayfield.setText("29"); // Leap Year       // increment to 29
                        }
                    }
                    if (yr % 100 == 0) {
                        if (yr % 400 != 0) {
                            dayfield.setText("1");
                            int mnth = datechooser.return_index(monthfield.getText());
                            monthfield.setText(datechooser.Return_month(mnth + 1));

                            // not a leap year                             // jump to next month
                        }
                    }
                    dayfield.setText("29"); // leap year             // increment to 29th

                }
                if (yr % 4 != 0) {
                    dayfield.setText("1");
                    int mnth = datechooser.return_index(monthfield.getText());
                    monthfield.setText(datechooser.Return_month(mnth + 1)); // not a leap year
                }

            } else if (dayfield.getText().equals("29")) { // at 29 jump to next month normally
                dayfield.setText("1");

                int mnth = datechooser.return_index(monthfield.getText());
                monthfield.setText(datechooser.Return_month(mnth + 1));
                // incrementing normal values/////////////////////// for february separately
            } else if (dayfield.getText().equals("1") || dayfield.getText().equals("2")
                    || dayfield.getText().equals("3") || dayfield.getText().equals("4")
                    || dayfield.getText().equals("5") || dayfield.getText().equals("6")
                    || dayfield.getText().equals("7") || dayfield.getText().equals("8")
                    || dayfield.getText().equals("9") || dayfield.getText().equals("10")
                    || dayfield.getText().equals("11") || dayfield.getText().equals("12")
                    || dayfield.getText().equals("13") || dayfield.getText().equals("14")
                    || dayfield.getText().equals("15") || dayfield.getText().equals("16")
                    || dayfield.getText().equals("17") || dayfield.getText().equals("18")
                    || dayfield.getText().equals("19") || dayfield.getText().equals("20")
                    || dayfield.getText().equals("21") || dayfield.getText().equals("22")
                    || dayfield.getText().equals("23") || dayfield.getText().equals("24")
                    || dayfield.getText().equals("25") || dayfield.getText().equals("26")
                    || dayfield.getText().equals("27") || dayfield.getText().equals("28")
                    || dayfield.getText().equals("29") || dayfield.getText().equals("30")
                    || dayfield.getText().equals("31")) {

                dayfield.setText("" + (Integer.parseInt(dayfield.getText()) + 1));

            }
            dayfield.selectAll();
        }
        // incrementing normal values
    } else if (dayfield.getText().equals("1") || dayfield.getText().equals("2")
            || dayfield.getText().equals("3") || dayfield.getText().equals("4")
            || dayfield.getText().equals("5") || dayfield.getText().equals("6")
            || dayfield.getText().equals("7") || dayfield.getText().equals("8")
            || dayfield.getText().equals("9") || dayfield.getText().equals("10")
            || dayfield.getText().equals("11") || dayfield.getText().equals("12")
            || dayfield.getText().equals("13") || dayfield.getText().equals("14")
            || dayfield.getText().equals("15") || dayfield.getText().equals("16")
            || dayfield.getText().equals("17") || dayfield.getText().equals("18")
            || dayfield.getText().equals("19") || dayfield.getText().equals("20")
            || dayfield.getText().equals("21") || dayfield.getText().equals("22")
            || dayfield.getText().equals("23") || dayfield.getText().equals("24")
            || dayfield.getText().equals("25") || dayfield.getText().equals("26")
            || dayfield.getText().equals("27") || dayfield.getText().equals("28")
            || dayfield.getText().equals("29") || dayfield.getText().equals("30")
            || dayfield.getText().equals("31")) {
        if (evt.getKeyCode() == KeyEvent.VK_UP) {

            dayfield.setText("" + (Integer.parseInt(dayfield.getText()) + 1));
            dayfield.selectAll();

        }
    }
    if (evt.getKeyCode() == KeyEvent.VK_RIGHT) {
        monthfield.requestFocus();
        monthfield.selectAll();
    }

    if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
    }
}

From source file:net.sf.jabref.gui.BasePanel.java

private void createMainTable() {
    database.registerListener(tableModel.getListSynchronizer());
    database.registerListener(SpecialFieldDatabaseChangeListener.getInstance());

    tableFormat = new MainTableFormat(database);
    tableFormat.updateTableFormat();//from  w  w  w  .j ava  2s.c o m
    mainTable = new MainTable(tableFormat, tableModel, frame, this);

    selectionListener = new MainTableSelectionListener(this, mainTable);
    mainTable.updateFont();
    mainTable.addSelectionListener(selectionListener);
    mainTable.addMouseListener(selectionListener);
    mainTable.addKeyListener(selectionListener);
    mainTable.addFocusListener(selectionListener);

    // Add the listener that will take care of highlighting groups as the selection changes:
    groupsHighlightListener = listEvent -> {
        HighlightMatchingGroupPreferences highlightMatchingGroupPreferences = new HighlightMatchingGroupPreferences(
                Globals.prefs);
        if (highlightMatchingGroupPreferences.isAny()) {
            getGroupSelector().showMatchingGroups(mainTable.getSelectedEntries(), false);
        } else if (highlightMatchingGroupPreferences.isAll()) {
            getGroupSelector().showMatchingGroups(mainTable.getSelectedEntries(), true);
        } else {
            // no highlight
            getGroupSelector().showMatchingGroups(null, true);
        }
    };
    mainTable.addSelectionListener(groupsHighlightListener);

    mainTable.getActionMap().put(Actions.CUT, new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                runCommand(Actions.CUT);
            } catch (Throwable ex) {
                LOGGER.warn("Could not cut", ex);
            }
        }
    });
    mainTable.getActionMap().put(Actions.COPY, new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                runCommand(Actions.COPY);
            } catch (Throwable ex) {
                LOGGER.warn("Could not copy", ex);
            }
        }
    });
    mainTable.getActionMap().put(Actions.PASTE, new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                runCommand(Actions.PASTE);
            } catch (Throwable ex) {
                LOGGER.warn("Could not paste", ex);
            }
        }
    });

    mainTable.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            final int keyCode = e.getKeyCode();
            final TreePath path = frame.getGroupSelector().getSelectionPath();
            final GroupTreeNodeViewModel node = path == null ? null
                    : (GroupTreeNodeViewModel) path.getLastPathComponent();

            if (e.isControlDown()) {
                switch (keyCode) {
                // The up/down/left/rightkeystrokes are displayed in the
                // GroupSelector's popup menu, so if they are to be changed,
                // edit GroupSelector.java accordingly!
                case KeyEvent.VK_UP:
                    e.consume();
                    if (node != null) {
                        frame.getGroupSelector().moveNodeUp(node, true);
                    }
                    break;
                case KeyEvent.VK_DOWN:
                    e.consume();
                    if (node != null) {
                        frame.getGroupSelector().moveNodeDown(node, true);
                    }
                    break;
                case KeyEvent.VK_LEFT:
                    e.consume();
                    if (node != null) {
                        frame.getGroupSelector().moveNodeLeft(node, true);
                    }
                    break;
                case KeyEvent.VK_RIGHT:
                    e.consume();
                    if (node != null) {
                        frame.getGroupSelector().moveNodeRight(node, true);
                    }
                    break;
                case KeyEvent.VK_PAGE_DOWN:
                    frame.nextTab.actionPerformed(null);
                    e.consume();
                    break;
                case KeyEvent.VK_PAGE_UP:
                    frame.prevTab.actionPerformed(null);
                    e.consume();
                    break;
                default:
                    break;
                }
            } else if (keyCode == KeyEvent.VK_ENTER) {
                e.consume();
                try {
                    runCommand(Actions.EDIT);
                } catch (Throwable ex) {
                    LOGGER.warn("Could not run action based on key press", ex);
                }
            }
        }
    });
}

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  w ww .j  av  a  2  s. 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();
    }
}