List of usage examples for java.awt.event KeyEvent VK_HOME
int VK_HOME
To view the source code for java.awt.event KeyEvent VK_HOME.
Click Source Link
From source file:Console.java
public void keyPressed(KeyEvent e) { int code = e.getKeyCode(); if (code == KeyEvent.VK_BACK_SPACE || code == KeyEvent.VK_LEFT) { if (outputMark == getCaretPosition()) { e.consume();/* www. j av a 2 s .c om*/ } } else if (code == KeyEvent.VK_HOME) { int caretPos = getCaretPosition(); if (caretPos == outputMark) { e.consume(); } else if (caretPos > outputMark) { if (!e.isControlDown()) { if (e.isShiftDown()) { moveCaretPosition(outputMark); } else { setCaretPosition(outputMark); } e.consume(); } } } else if (code == KeyEvent.VK_ENTER) { returnPressed(); e.consume(); } else if (code == KeyEvent.VK_UP) { historyIndex--; if (historyIndex >= 0) { if (historyIndex >= history.size()) { historyIndex = history.size() - 1; } if (historyIndex >= 0) { String str = history.elementAt(historyIndex); int len = getDocument().getLength(); replaceRange(str, outputMark, len); int caretPos = outputMark + str.length(); select(caretPos, caretPos); } else { historyIndex++; } } else { historyIndex++; } e.consume(); } else if (code == KeyEvent.VK_DOWN) { int caretPos = outputMark; if (history.size() > 0) { historyIndex++; if (historyIndex < 0) { historyIndex = 0; } int len = getDocument().getLength(); if (historyIndex < history.size()) { String str = history.elementAt(historyIndex); replaceRange(str, outputMark, len); caretPos = outputMark + str.length(); } else { historyIndex = history.size(); replaceRange("", outputMark, len); } } select(caretPos, caretPos); e.consume(); } }
From source file:DateTimeEditor.java
protected void setupKeymap() { Keymap keymap = m_textField.addKeymap("DateTimeKeymap", null); keymap.addActionForKeyStroke(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), m_upAction); keymap.addActionForKeyStroke(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), m_downAction); keymap.addActionForKeyStroke(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0), new BackwardAction(DefaultEditorKit.backwardAction)); keymap.addActionForKeyStroke(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0), new ForwardAction(DefaultEditorKit.forwardAction)); keymap.addActionForKeyStroke(KeyStroke.getKeyStroke(KeyEvent.VK_HOME, 0), new BeginAction(DefaultEditorKit.beginAction)); keymap.addActionForKeyStroke(KeyStroke.getKeyStroke(KeyEvent.VK_END, 0), new EndAction(DefaultEditorKit.endAction)); m_textField.setKeymap(keymap);//from w w w. ja va2 s. c o m }
From source file:com.floreantpos.jasperreport.swing.JRViewerPanel.java
protected void keyNavigate(KeyEvent evt) { boolean refresh = true; switch (evt.getKeyCode()) { case KeyEvent.VK_DOWN: case KeyEvent.VK_PAGE_DOWN: dnNavigate(evt);/*from w ww. j a va2s .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(viewerContext.getPageCount() - 1); break; default: refresh = false; } if (refresh) { viewerContext.refreshPage(); } }
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); }// w w w.j ava 2 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: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. * /*from w w w .ja v a 2 s. co m*/ * @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); // Not any of the 2 rotations don't act simultaneously. switch (keyCode) { case KeyEvent.VK_HOME: // Home - rotate up rotation.rotX(angle); break; case KeyEvent.VK_END: // End - rotate down rotation.rotX(-angle); break; default: rotation.rotX(0.0f); } myKeyNavTransf3D.mul(rotation); // Return the final transformation myKeyNavTransf3D to target target_trGr.setTransform(myKeyNavTransf3D); } // Set wakeup criteria for next time. wakeupOn(wakeUp); }
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);// ww w . ja v a 2s.com } } 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);/* ww w . j a va 2 s .c om*/ 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:edu.ku.brc.specify.tasks.subpane.wb.wbuploader.Uploader.java
public void keyPressed(KeyEvent e) { logDebug("keyPressed"); int key = e.getKeyCode(); if (key == KeyEvent.VK_ENTER || key == KeyEvent.VK_TAB || key == KeyEvent.VK_DOWN || key == KeyEvent.VK_UP || (key == KeyEvent.VK_TAB && e.isShiftDown()) || key == KeyEvent.VK_HOME || key == KeyEvent.VK_END) { editInvalidCell(e);//from w w w . ja va 2 s . c o m e.consume(); } }
From source file:edu.ku.brc.specify.tasks.subpane.wb.wbuploader.Uploader.java
/** * @param e//ww w . j a v a 2 s . c o m * * Moves to WB cell for appropriate InvalidValue and starts editing it. */ protected void editInvalidCell(KeyEvent e) { logDebug("editing invalid cell"); int key = e.getKeyCode(); if (key == KeyEvent.VK_ENTER || key == KeyEvent.VK_TAB || key == KeyEvent.VK_DOWN) goToNextInvalidCell(); else if (key == KeyEvent.VK_UP || (key == KeyEvent.VK_TAB && e.isShiftDown())) goToPrevInvalidCell(); else if (key == KeyEvent.VK_HOME) goToFirstInvalidCell(); else if (key == KeyEvent.VK_END) goToLastInvalidCell(); }
From source file:org.jab.docsearch.DocSearch.java
private JToolBar createToolBar() { // tool bar/*w w w . j a v a 2s .c o m*/ JToolBar toolBar = new JToolBar(); // file open JButton buttonOpen = new JButton(new ImageIcon(getClass().getResource("/icons/fileopen.png"))); buttonOpen.setToolTipText(I18n.getString("tooltip.open")); buttonOpen.setActionCommand("ac_open"); buttonOpen.addActionListener(this); buttonOpen.setMnemonic(KeyEvent.VK_O); buttonOpen.setEnabled(!env.isWebStart()); // disable in WebStart toolBar.add(buttonOpen); // file save JButton buttonSave = new JButton(new ImageIcon(getClass().getResource("/icons/filesave.png"))); buttonSave.setToolTipText(I18n.getString("tooltip.save")); buttonSave.setActionCommand("ac_save"); buttonSave.addActionListener(this); buttonSave.setMnemonic(KeyEvent.VK_S); buttonSave.setEnabled(!env.isWebStart()); // disable in WebStart toolBar.add(buttonSave); toolBar.addSeparator(); // open browser JButton buttonBrowser = new JButton(new ImageIcon(getClass().getResource("/icons/html.png"))); buttonBrowser.setToolTipText(I18n.getString("tooltip.open_in_browser")); buttonBrowser.setActionCommand("ac_openinbrowser"); buttonBrowser.addActionListener(this); buttonBrowser.setMnemonic(KeyEvent.VK_E); buttonBrowser.setEnabled(!env.isWebStart()); // disable in WebStart toolBar.add(buttonBrowser); toolBar.addSeparator(); // home JButton buttonHome = new JButton(new ImageIcon(getClass().getResource("/icons/home.png"))); buttonHome.setToolTipText(I18n.getString("tooltip.home")); buttonHome.setActionCommand("ac_home"); buttonHome.addActionListener(this); buttonHome.setMnemonic(KeyEvent.VK_H); toolBar.add(buttonHome); // refresh JButton buttonRefresh = new JButton(new ImageIcon(getClass().getResource("/icons/refresh.png"))); buttonRefresh.setToolTipText(I18n.getString("tooltip.refresh")); buttonRefresh.setActionCommand("ac_refresh"); buttonRefresh.addActionListener(this); buttonRefresh.setMnemonic(KeyEvent.VK_L); toolBar.add(buttonRefresh); toolBar.addSeparator(); // result JButton buttonResult = new JButton(new ImageIcon(getClass().getResource("/icons/search_results.png"))); buttonResult.setToolTipText(I18n.getString("tooltip.results")); buttonResult.setActionCommand("ac_result"); buttonResult.addActionListener(this); buttonResult.setMnemonic(KeyEvent.VK_R); toolBar.add(buttonResult); toolBar.addSeparator(); // bookmark JButton buttonBookMark = new JButton(new ImageIcon(getClass().getResource("/icons/bookmark.png"))); buttonBookMark.setToolTipText(I18n.getString("tooltip.add_bookmark")); buttonBookMark.setActionCommand("ac_addbookmark"); buttonBookMark.addActionListener(this); buttonBookMark.setMnemonic(KeyEvent.VK_M); toolBar.add(buttonBookMark); toolBar.addSeparator(); // print JButton buttonPrint = new JButton(new ImageIcon(getClass().getResource("/icons/fileprint.png"))); buttonPrint.setToolTipText(I18n.getString("tooltip.print")); buttonPrint.setActionCommand("ac_print"); buttonPrint.addActionListener(this); buttonPrint.setMnemonic(KeyEvent.VK_P); toolBar.add(buttonPrint); toolBar.addSeparator(); // setting JButton buttonSetting = new JButton(new ImageIcon(getClass().getResource("/icons/configure.png"))); buttonSetting.setToolTipText(I18n.getString("tooltip.settings")); buttonSetting.setActionCommand("ac_settings"); buttonSetting.addActionListener(this); buttonSetting.setMnemonic(KeyEvent.VK_HOME); toolBar.add(buttonSetting); toolBar.addSeparator(); // stop buttonStop = new JButton(new ImageIcon(getClass().getResource("/icons/stop.png"))); buttonStop.setToolTipText(I18n.getString("tooltip.stop")); buttonStop.setActionCommand("ac_stop"); buttonStop.addActionListener(this); buttonStop.setMnemonic(KeyEvent.VK_X); toolBar.add(buttonStop); toolBar.addSeparator(); // toolBar.setFloatable(false); // finished return toolBar; }