List of usage examples for java.awt.event KeyEvent VK_DOWN
int VK_DOWN
To view the source code for java.awt.event KeyEvent VK_DOWN.
Click Source Link
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();/* w w w .j ava2 s . c om*/ } 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:org.safs.selenium.webdriver.lib.WDLibrary.java
/** * Convert a Java KEYCODE to a Selenium WebDriver Keys Enum * @param keycode int, a java keycode/*w w w .j a v a 2s . c o m*/ * @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:org.nuclos.client.genericobject.GenericObjectCollectController.java
private void setupKeyActionsForResultPanelVerticalScrollBar() { // maps the default key strokes for JTable to set the vertical scrollbar, so we can intervent: final InputMap inputmap = getResultTable().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); inputmap.put(KeyStroke.getKeyStroke(KeyEvent.VK_END, InputEvent.CTRL_MASK), "last"); inputmap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), "nextrow"); inputmap.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, 0), "nextpage"); final JScrollBar scrlbarVertical = getResultPanel().getResultTableScrollPane().getVerticalScrollBar(); final DefaultBoundedRangeModel model = (DefaultBoundedRangeModel) scrlbarVertical.getModel(); getResultTable().getActionMap().put("last", new AbstractAction() { @Override/*from ww w. jav a 2 s . c om*/ public void actionPerformed(ActionEvent ev) { final int iSupposedValue = model.getMaximum() - model.getExtent(); model.setValue(iSupposedValue); // this causes the necessary rows to be loaded. Loading may be cancelled by the user. LOG.debug("NOW it's time to select the row..."); if (model.getValue() == iSupposedValue) getCollectNavigationModel().selectLastElement(); } }); getResultTable().getActionMap().put("nextrow", new AbstractAction() { @Override public void actionPerformed(ActionEvent ev) { final int iSelectedRow = getResultTable().getSelectedRow(); final int iLastVisibleRow = TableUtils.getLastVisibleRow(getResultTable()); if (iSelectedRow + 1 < iLastVisibleRow) { // next row is still visible: just select it: if (!getCollectNavigationModel().isLastElementSelected()) getCollectNavigationModel().selectNextElement(); } else { // we have to move the viewport before we can select the next row: final int iSupposedValue = Math.min(model.getValue() + getResultTable().getRowHeight(), model.getMaximum() - model.getExtent()); model.setValue(iSupposedValue); // this causes the necessary rows to be loaded. Loading may be cancelled by the user. LOG.debug("NOW it's time to select the row..."); if (model.getValue() == iSupposedValue) if (!getCollectNavigationModel().isLastElementSelected()) getCollectNavigationModel().selectNextElement(); } } }); getResultTable().getActionMap().put("nextpage", new AbstractAction() { @Override public void actionPerformed(ActionEvent ev) { final int iSupposedValue = Math.min(model.getValue() + model.getExtent(), model.getMaximum() - model.getExtent()); model.setValue(iSupposedValue); // this causes the necessary rows to be loaded. Loading may be cancelled by the user. LOG.debug("NOW it's time to select the row..."); if (model.getValue() == iSupposedValue) { final int iShiftRowCount = (int) Math .ceil((double) model.getExtent() / (double) getResultTable().getRowHeight()); final int iRow = Math.min( getResultTable().getSelectionModel().getAnchorSelectionIndex() + iShiftRowCount, getResultTable().getRowCount() - 1); getResultTable().setRowSelectionInterval(iRow, iRow); } } }); final Action actShowLogBook = new AbstractAction() { @Override public void actionPerformed(ActionEvent ev) { cmdShowLogBook(); getDetailsPanel().grabFocus(); } }; KeyBindingProvider.bindActionToComponent(KeyBindingProvider.SHOW_LOGBOOK, actShowLogBook, getDetailsPanel()); final Action actShowStateHistory = new AbstractAction() { @Override public void actionPerformed(ActionEvent ev) { cmdShowStateHistory(); getDetailsPanel().grabFocus(); } }; KeyBindingProvider.bindActionToComponent(KeyBindingProvider.SHOW_STATE_HISTORIE, actShowStateHistory, getDetailsPanel()); final Action actPrintCurrentGenericObject = new AbstractAction() { @Override public void actionPerformed(ActionEvent ev) { cmdPrintCurrentGenericObject(); getDetailsPanel().grabFocus(); } }; KeyBindingProvider.bindActionToComponent(KeyBindingProvider.PRINT_LEASED_OBJECT, actPrintCurrentGenericObject, getDetailsPanel()); }
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();//from www . j a v a2s . c o m } 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 . j a va2s.c om*/ } 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: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 }// ww w . ja va2s . 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();/* ww w . j a v a2 s . 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 w w . j a v a 2 s. c o m*/ } } 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:cn.pholance.datamanager.common.components.JRViewer.java
protected void keyNavigate(KeyEvent evt) { boolean refresh = true; switch (evt.getKeyCode()) { case KeyEvent.VK_DOWN: case KeyEvent.VK_PAGE_DOWN: dnNavigate(evt);//from ww w .j a va2 s . c o m break; case KeyEvent.VK_UP: case KeyEvent.VK_PAGE_UP: upNavigate(evt); break; case KeyEvent.VK_HOME: homeEndNavigate(0); break; case KeyEvent.VK_END: homeEndNavigate(jasperPrint.getPages().size() - 1); break; default: refresh = false; } if (refresh) { refreshPage(); } }
From source file:Demo3D.java
/** * Override Behavior's stimulus method to handle the event. This method is * called when a key on the keyboard has been pressed and operates on the * specified transform group to move the camera. * /*w w w. j a v a2s. c om*/ * @param Enumeration * criteria - all pressed keys in a list. This will be passed by * the system. */ public void processStimulus(Enumeration criteria) { WakeupOnAWTEvent eventToWakeUp; AWTEvent[] events; if (criteria.hasMoreElements()) { // Decode the wakeup criteria eventToWakeUp = (WakeupOnAWTEvent) criteria.nextElement(); events = eventToWakeUp.getAWTEvent(); keyEvent = (KeyEvent) events[0]; int keyCode = keyEvent.getKeyCode(); // Perform our processing // Get the initial transformation from target and put it into // myKeyNavTransf3D target_trGr.getTransform(myKeyNavTransf3D); // Set the translational components of myKeyNavTransf3D in // translation myKeyNavTransf3D.get(translation); // Not any of the 8 motions (6 translations and 2 rotations) // don't act simultaneously. switch (keyCode) { case KeyEvent.VK_UP: // Up Arrow - to move forward trans_rot.set(new Vector3f(0.0f, 0.0f, -step)); break; case KeyEvent.VK_DOWN: // Down Arrow - to move backwards trans_rot.set(new Vector3f(0.0f, 0.0f, step)); break; case KeyEvent.VK_LEFT: // Left Arrow -to turn left or move left if (keyEvent.isShiftDown()) trans_rot.set(new Vector3f(-step, 0.0f, 0.0f)); else trans_rot.rotY(angle); break; case KeyEvent.VK_RIGHT: // Right Arrow - to turn right or move right if (keyEvent.isShiftDown()) trans_rot.set(new Vector3f(step, 0.0f, 0.0f)); else trans_rot.rotY(-angle); break; case KeyEvent.VK_PAGE_DOWN: // Page Down - to move down trans_rot.set(new Vector3f(0.0f, -step, 0.0f)); break; case KeyEvent.VK_PAGE_UP: // Page Up - to move up trans_rot.set(new Vector3f(0.0f, step, 0.0f)); break; default: trans_rot.set(new Vector3f(0.0f, 0.0f, 0.0f)); } myKeyNavTransf3D.mul(trans_rot); // Return the final transformation myKeyNavTransf3D to target target_trGr.setTransform(myKeyNavTransf3D); } // Set wakeup criteria for next time. wakeupOn(wakeUp); }