Java Code Examples for java.awt.event.KeyEvent#VK_PAGE_UP
The following examples show how to use
java.awt.event.KeyEvent#VK_PAGE_UP .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ListDelegationUtil.java From consulo with Apache License 2.0 | 5 votes |
public static ActionCallback installKeyboardDelegation(final JComponent focusedComponent, final JList delegateTo) { final KeyListener keyListener = new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { final int code = e.getKeyCode(); final int modifiers = e.getModifiers(); switch (code) { case KeyEvent.VK_UP: ScrollingUtil.moveUp(delegateTo, modifiers); break; case KeyEvent.VK_DOWN: ScrollingUtil.moveDown(delegateTo, modifiers); break; case KeyEvent.VK_HOME: ScrollingUtil.moveHome(delegateTo); break; case KeyEvent.VK_END: ScrollingUtil.moveEnd(delegateTo); break; case KeyEvent.VK_PAGE_UP: ScrollingUtil.movePageUp(delegateTo); break; case KeyEvent.VK_PAGE_DOWN: ScrollingUtil.movePageDown(delegateTo); break; } } }; focusedComponent.addKeyListener(keyListener); final ActionCallback callback = new ActionCallback(); callback.doWhenProcessed(() -> focusedComponent.removeKeyListener(keyListener)); return callback; }
Example 2
Source File: JBinaryViewer.java From freeinternals with Apache License 2.0 | 5 votes |
@Override public void keyPressed(final KeyEvent e) { switch (e.getKeyCode()) { case KeyEvent.VK_HOME: JBinaryViewer.this.vBar.setValue(JBinaryViewer.this.vBar.getMinimum()); break; case KeyEvent.VK_END: JBinaryViewer.this.vBar.setValue(JBinaryViewer.this.vBar.getMaximum()); break; case KeyEvent.VK_UP: JBinaryViewer.this.vBar.setValue(JBinaryViewer.this.vBar.getValue() - 1); break; case KeyEvent.VK_DOWN: JBinaryViewer.this.vBar.setValue(JBinaryViewer.this.vBar.getValue() + 1); break; case KeyEvent.VK_LEFT: case KeyEvent.VK_PAGE_UP: JBinaryViewer.this.vBar.setValue(JBinaryViewer.this.vBar.getValue() - JBinaryViewer.this.vBar.getVisibleAmount()); break; case KeyEvent.VK_RIGHT: case KeyEvent.VK_PAGE_DOWN: JBinaryViewer.this.vBar.setValue(JBinaryViewer.this.vBar.getValue() + JBinaryViewer.this.vBar.getVisibleAmount()); break; default: break; } }
Example 3
Source File: TradeScreen.java From open-ig with GNU Lesser General Public License v3.0 | 5 votes |
@Override public boolean keyboard(KeyEvent e) { switch (e.getKeyCode()) { case KeyEvent.VK_UP: { selectByRow(-1); e.consume(); return true; } case KeyEvent.VK_PAGE_UP: { selectByRow(-rowCount); e.consume(); return true; } case KeyEvent.VK_DOWN: { selectByRow(1); e.consume(); return true; } case KeyEvent.VK_PAGE_DOWN: { selectByRow(rowCount); e.consume(); return true; } default: } return super.keyboard(e); }
Example 4
Source File: SwingTextKeyboardDriver.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Override public NavigationKey[] getKeys(ComponentOperator oper) { boolean multiString = oper instanceof JTextAreaOperator || oper instanceof JEditorPaneOperator; NavigationKey[] result = new NavigationKey[multiString ? 8 : 4]; result[0] = new UpKey(KeyEvent.VK_LEFT, 0); result[1] = new DownKey(KeyEvent.VK_RIGHT, 0); ((UpKey) result[0]).setDownKey((DownKey) result[1]); ((DownKey) result[1]).setUpKey((UpKey) result[0]); if (multiString) { result[2] = new UpKey(KeyEvent.VK_UP, 0); result[3] = new DownKey(KeyEvent.VK_DOWN, 0); ((UpKey) result[2]).setDownKey((DownKey) result[3]); ((DownKey) result[3]).setUpKey((UpKey) result[2]); result[4] = new UpKey(KeyEvent.VK_PAGE_UP, 0); result[5] = new DownKey(KeyEvent.VK_PAGE_DOWN, 0); ((UpKey) result[4]).setDownKey((DownKey) result[5]); ((DownKey) result[5]).setUpKey((UpKey) result[4]); result[6] = new HomeKey(KeyEvent.VK_HOME, InputEvent.CTRL_MASK); result[7] = new EndKey(KeyEvent.VK_END, InputEvent.CTRL_MASK, this, oper); } else { result[2] = new HomeKey(KeyEvent.VK_HOME, 0); result[3] = new EndKey(KeyEvent.VK_END, 0, this, oper); } return result; }
Example 5
Source File: ImageCommand.java From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 | 5 votes |
public int getKeyEvent(String key) { switch (key.toUpperCase()) { case "TAB": return KeyEvent.VK_TAB; case "ENTER": return KeyEvent.VK_ENTER; case "SHIFT": return KeyEvent.VK_SHIFT; case "CTRL": return KeyEvent.VK_CONTROL; case "ALT": return KeyEvent.VK_ALT; case "START": return KeyEvent.VK_WINDOWS; case "DELETE": return KeyEvent.VK_DELETE; case "BACKSPACE": return KeyEvent.VK_BACK_SPACE; case "HOME": return KeyEvent.VK_HOME; case "PAGE_UP": case "PAGEUP": return KeyEvent.VK_PAGE_UP; case "PAGE_DOWN": case "PAGEDOWN": return KeyEvent.VK_PAGE_DOWN; case "UP": return KeyEvent.VK_UP; case "DOWN": return KeyEvent.VK_DOWN; case "LEFT": return KeyEvent.VK_LEFT; case "RIGHT": return KeyEvent.VK_RIGHT; default: return KeyEvent.VK_ESCAPE; } }
Example 6
Source File: NetAdmin.java From nullpomino with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void keyPressed(KeyEvent e) { if( (e.getKeyCode() != KeyEvent.VK_UP) && (e.getKeyCode() != KeyEvent.VK_DOWN) && (e.getKeyCode() != KeyEvent.VK_LEFT) && (e.getKeyCode() != KeyEvent.VK_RIGHT) && (e.getKeyCode() != KeyEvent.VK_HOME) && (e.getKeyCode() != KeyEvent.VK_END) && (e.getKeyCode() != KeyEvent.VK_PAGE_UP) && (e.getKeyCode() != KeyEvent.VK_PAGE_DOWN) && ((e.getKeyCode() != KeyEvent.VK_A) || (e.isControlDown() == false)) && ((e.getKeyCode() != KeyEvent.VK_C) || (e.isControlDown() == false)) && (!e.isAltDown()) ) { e.consume(); } }
Example 7
Source File: JRViewerPanel.java From jasperreports with GNU Lesser General Public License v3.0 | 5 votes |
protected void keyNavigate(KeyEvent evt) { boolean refresh = true; switch (evt.getKeyCode()) { case KeyEvent.VK_DOWN: case KeyEvent.VK_PAGE_DOWN: dnNavigate(evt); 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(); } }
Example 8
Source File: JRViewer.java From nordpos with GNU General Public License v3.0 | 5 votes |
protected void keyNavigate(KeyEvent evt) { boolean refresh = true; switch (evt.getKeyCode()) { case KeyEvent.VK_DOWN: case KeyEvent.VK_PAGE_DOWN: dnNavigate(evt); 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(); } }
Example 9
Source File: KeyboardTabSwitcher.java From otroslogviewer with Apache License 2.0 | 5 votes |
@Override public boolean postProcessKeyEvent(KeyEvent e) { if (e.getID() == KeyEvent.KEY_PRESSED && e.getModifiers() == InputEvent.CTRL_MASK) { if (e.getKeyCode() == KeyEvent.VK_PAGE_DOWN || e.getKeyCode() == KeyEvent.VK_LEFT) { goPrevPane(); return true; } else if (e.getKeyCode() == KeyEvent.VK_PAGE_UP || e.getKeyCode() == KeyEvent.VK_RIGHT) { goNextPane(); return true; } } return false; }
Example 10
Source File: SelectionTool.java From workcraft with MIT License | 4 votes |
@Override public boolean keyPressed(GraphEditorKeyEvent e) { GraphEditor editor = e.getEditor(); switch (e.getKeyCode()) { case KeyEvent.VK_ESCAPE: if (isDragging()) { cancelDrag(editor); } else { cancelSelection(editor); } return true; case KeyEvent.VK_PAGE_UP: changeLevelUp(editor); return true; case KeyEvent.VK_PAGE_DOWN: changeLevelDown(editor); return true; } if (!e.isMenuKeyDown() && !e.isShiftKeyDown()) { switch (e.getKeyCode()) { case KeyEvent.VK_LEFT: offsetSelection(editor, -1, 0); return true; case KeyEvent.VK_RIGHT: offsetSelection(editor, 1, 0); return true; case KeyEvent.VK_UP: offsetSelection(editor, 0, -1); return true; case KeyEvent.VK_DOWN: offsetSelection(editor, 0, 1); return true; } } if (enablePaging && e.isAltKeyDown() && !e.isMenuKeyDown()) { switch (e.getKeyCode()) { case KeyEvent.VK_G: if (e.isShiftKeyDown()) { ungroupSelection(editor); } else { pageSelection(editor); } return true; } } if (enableGroupping && e.isMenuKeyDown() && !e.isAltKeyDown()) { switch (e.getKeyCode()) { case KeyEvent.VK_G: if (e.isShiftKeyDown()) { ungroupSelection(editor); } else { groupSelection(editor); } return true; } } if (e.isMenuKeyDown() && !e.isAltKeyDown()) { switch (e.getKeyCode()) { case KeyEvent.VK_V: Point2D pastePosition = TransformHelper.snapP5(currentMousePosition); editor.getWorkspaceEntry().setPastePosition(pastePosition); return true; } } if (e.isExtendKeyDown()) { currentNodes = getNodeWithAdjacentConnections(e.getModel(), currentNode); editor.repaint(); return true; } return super.keyPressed(e); }
Example 11
Source File: ProjectTree.java From TrakEM2 with GNU General Public License v3.0 | 4 votes |
@Override public void keyPressed(final KeyEvent ke) { super.keyPressed(ke); if (ke.isConsumed()) return; if (!ke.getSource().equals(ProjectTree.this) || !project.isInputEnabled()) { return; } // get the first selected node only TreePath path = getSelectionPath(); if (null == path) return; DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent(); if (null == node) return; final ProjectThing pt = (ProjectThing)node.getUserObject(); if (null == pt) return; // final int flags = ke.getModifiers(); switch (ke.getKeyCode()) { case KeyEvent.VK_PAGE_UP: move(node, -1); ke.consume(); // in any case break; case KeyEvent.VK_PAGE_DOWN: move(node, 1); ke.consume(); // in any case break; case KeyEvent.VK_F2: rename(pt); ke.consume(); break; case KeyEvent.VK_H: if (0 == (flags ^ Event.ALT_MASK)) { pt.setVisible(true); ke.consume(); } else if (0 == flags) { pt.setVisible(false); ke.consume(); } break; case KeyEvent.VK_A: if (0 == flags || (0 == (flags ^ Event.SHIFT_MASK))) { selectInDisplay(pt, 0 == (flags ^ Event.SHIFT_MASK)); ke.consume(); } break; case KeyEvent.VK_3: if (0 == flags) { ini.trakem2.display.Display3D.showAndResetView(pt); ke.consume(); break; } // else, flow: case KeyEvent.VK_1: case KeyEvent.VK_2: case KeyEvent.VK_4: case KeyEvent.VK_5: case KeyEvent.VK_6: case KeyEvent.VK_7: case KeyEvent.VK_8: case KeyEvent.VK_9: // run a plugin, if any if (pt.getObject() instanceof Displayable && null != Utils.launchTPlugIn(ke, "Project Tree", project, (Displayable)pt.getObject())) { ke.consume(); } break; } ke.consume(); }
Example 12
Source File: VncClientPacketSender.java From cosmic with Apache License 2.0 | 4 votes |
private int mapAwtKeyToVncKey(final int key) { switch (key) { case KeyEvent.VK_BACK_SPACE: return 0xff08; case KeyEvent.VK_TAB: return 0xff09; case KeyEvent.VK_ENTER: return 0xff0d; case KeyEvent.VK_ESCAPE: return 0xff1b; case KeyEvent.VK_INSERT: return 0xff63; case KeyEvent.VK_DELETE: return 0xffff; case KeyEvent.VK_HOME: return 0xff50; case KeyEvent.VK_END: return 0xff57; case KeyEvent.VK_PAGE_UP: return 0xff55; case KeyEvent.VK_PAGE_DOWN: return 0xff56; case KeyEvent.VK_LEFT: return 0xff51; case KeyEvent.VK_UP: return 0xff52; case KeyEvent.VK_RIGHT: return 0xff53; case KeyEvent.VK_DOWN: return 0xff54; case KeyEvent.VK_F1: return 0xffbe; case KeyEvent.VK_F2: return 0xffbf; case KeyEvent.VK_F3: return 0xffc0; case KeyEvent.VK_F4: return 0xffc1; case KeyEvent.VK_F5: return 0xffc2; case KeyEvent.VK_F6: return 0xffc3; case KeyEvent.VK_F7: return 0xffc4; case KeyEvent.VK_F8: return 0xffc5; case KeyEvent.VK_F9: return 0xffc6; case KeyEvent.VK_F10: return 0xffc7; case KeyEvent.VK_F11: return 0xffc8; case KeyEvent.VK_F12: return 0xffc9; case KeyEvent.VK_SHIFT: return 0xffe1; case KeyEvent.VK_CONTROL: return 0xffe3; case KeyEvent.VK_META: return 0xffe7; case KeyEvent.VK_ALT: return 0xffe9; case KeyEvent.VK_ALT_GRAPH: return 0xffea; case KeyEvent.VK_BACK_QUOTE: return 0x0060; } return key; }
Example 13
Source File: CfgPropsDialog.java From nb-springboot with Apache License 2.0 | 4 votes |
@Override public void keyPressed(KeyEvent e) { final int keyCode = e.getKeyCode(); if (keyCode == KeyEvent.VK_ESCAPE) { final String filter = txtField.getText(); if (filter == null || filter.isEmpty()) { // close dialog if filter textfield is empty setVisible(false); } else { // clear textfield txtField.setText(null); e.consume(); } } else { final int size = lCfgProps.getModel().getSize(); // short circuit if empty size if (size == 0) { return; } int selIdx = lCfgProps.getSelectedIndex(); final int pageStep = lCfgProps.getVisibleRowCount(); // calculate new index switch (keyCode) { case KeyEvent.VK_PAGE_UP: selIdx -= pageStep; // clamp to [0 : size-1] range if (selIdx < 0) { selIdx = 0; } else if (selIdx >= size) { selIdx = size - 1; } break; case KeyEvent.VK_UP: selIdx -= 1; // wrap if needed if (selIdx < 0) { selIdx += size; } else if (selIdx >= size) { selIdx -= size; } break; case KeyEvent.VK_DOWN: selIdx += 1; // wrap if needed if (selIdx < 0) { selIdx += size; } else if (selIdx >= size) { selIdx -= size; } break; case KeyEvent.VK_PAGE_DOWN: selIdx += pageStep; // clamp to [0 : size-1] range if (selIdx < 0) { selIdx = 0; } else if (selIdx >= size) { selIdx = size - 1; } break; } // move properties list selection and scroll to it lCfgProps.setSelectedIndex(selIdx); lCfgProps.scrollRectToVisible(lCfgProps.getCellBounds(selIdx, selIdx)); } }
Example 14
Source File: ActionUtils.java From workcraft with MIT License | 4 votes |
public static String getKeyString(int keyCode) { // Letters and numbers if (((keyCode >= KeyEvent.VK_0) && (keyCode <= KeyEvent.VK_9)) || ((keyCode >= KeyEvent.VK_A) && (keyCode <= KeyEvent.VK_Z))) { return String.valueOf((char) keyCode); } switch (keyCode) { // Navigation keys case KeyEvent.VK_LEFT: return "Left"; case KeyEvent.VK_UP: return "Up"; case KeyEvent.VK_RIGHT: return "Right"; case KeyEvent.VK_DOWN: return "Down"; // Extra navigation keys case KeyEvent.VK_INSERT: return "Insert"; case KeyEvent.VK_DELETE: return "Delete"; case KeyEvent.VK_END: return "End"; case KeyEvent.VK_HOME: return "Home"; case KeyEvent.VK_PAGE_UP: return "PgUp"; case KeyEvent.VK_PAGE_DOWN: return "PgDn"; // Function keys case KeyEvent.VK_F1: return "F1"; case KeyEvent.VK_F2: return "F2"; case KeyEvent.VK_F3: return "F3"; case KeyEvent.VK_F4: return "F4"; case KeyEvent.VK_F5: return "F5"; case KeyEvent.VK_F6: return "F6"; case KeyEvent.VK_F7: return "F7"; case KeyEvent.VK_F8: return "F8"; case KeyEvent.VK_F9: return "F9"; case KeyEvent.VK_F10: return "F10"; case KeyEvent.VK_F11: return "F11"; case KeyEvent.VK_F12: return "F12"; // Symbols case KeyEvent.VK_EXCLAMATION_MARK: return "!"; case KeyEvent.VK_QUOTEDBL: return "\""; case KeyEvent.VK_EURO_SIGN: return "€"; case KeyEvent.VK_DOLLAR: return "$"; case KeyEvent.VK_CIRCUMFLEX: return "^"; case KeyEvent.VK_AMPERSAND: return "&"; case KeyEvent.VK_ASTERISK: return "*"; case KeyEvent.VK_UNDERSCORE: return "_"; case KeyEvent.VK_MINUS: return "-"; case KeyEvent.VK_PLUS: return "+"; case KeyEvent.VK_EQUALS: return "="; case KeyEvent.VK_AT: return "@"; case KeyEvent.VK_NUMBER_SIGN: return "#"; case KeyEvent.VK_COLON: return ":"; case KeyEvent.VK_SEMICOLON: return ";"; case KeyEvent.VK_COMMA: return ","; case KeyEvent.VK_PERIOD: return "."; case KeyEvent.VK_SLASH: return "/"; case KeyEvent.VK_BACK_SLASH: return "\\"; case KeyEvent.VK_DEAD_TILDE: return "~"; // Parenthesis and brackets case KeyEvent.VK_LEFT_PARENTHESIS: return "("; case KeyEvent.VK_RIGHT_PARENTHESIS: return ")"; case KeyEvent.VK_OPEN_BRACKET: return "["; case KeyEvent.VK_CLOSE_BRACKET: return "]"; case KeyEvent.VK_BRACELEFT: return "{"; case KeyEvent.VK_BRACERIGHT: return "}"; case KeyEvent.VK_LESS: return "<"; case KeyEvent.VK_GREATER: return ">"; // Formatting keys case KeyEvent.VK_SPACE: return "Space"; case KeyEvent.VK_TAB: return "Tab"; case KeyEvent.VK_ENTER: return "Enter"; case KeyEvent.VK_BACK_SPACE: return "Backspace"; case KeyEvent.VK_ESCAPE: return "Esc"; } return "0x" + Integer.toString(keyCode, 16); }
Example 15
Source File: TableTabCaret.java From Logisim with GNU General Public License v3.0 | 4 votes |
@Override public void keyPressed(KeyEvent e) { if (cursorRow < 0) return; TruthTable model = table.getTruthTable(); int rows = model.getRowCount(); int inputs = model.getInputColumnCount(); int outputs = model.getOutputColumnCount(); int cols = inputs + outputs; boolean shift = (e.getModifiersEx() & InputEvent.SHIFT_DOWN_MASK) != 0; switch (e.getKeyCode()) { case KeyEvent.VK_UP: setCursor(cursorRow - 1, cursorCol, shift); break; case KeyEvent.VK_LEFT: setCursor(cursorRow, cursorCol - 1, shift); break; case KeyEvent.VK_DOWN: setCursor(cursorRow + 1, cursorCol, shift); break; case KeyEvent.VK_RIGHT: setCursor(cursorRow, cursorCol + 1, shift); break; case KeyEvent.VK_HOME: if (cursorCol == 0) setCursor(0, 0, shift); else setCursor(cursorRow, 0, shift); break; case KeyEvent.VK_END: if (cursorCol == cols - 1) setCursor(rows - 1, cols - 1, shift); else setCursor(cursorRow, cols - 1, shift); break; case KeyEvent.VK_PAGE_DOWN: rows = table.getVisibleRect().height / table.getCellHeight(); if (rows > 2) rows--; setCursor(cursorRow + rows, cursorCol, shift); break; case KeyEvent.VK_PAGE_UP: rows = table.getVisibleRect().height / table.getCellHeight(); if (rows > 2) rows--; setCursor(cursorRow - rows, cursorCol, shift); break; } }
Example 16
Source File: VncClientPacketSender.java From cloudstack with Apache License 2.0 | 4 votes |
private int mapAwtKeyToVncKey(int key) { switch (key) { case KeyEvent.VK_BACK_SPACE: return 0xff08; case KeyEvent.VK_TAB: return 0xff09; case KeyEvent.VK_ENTER: return 0xff0d; case KeyEvent.VK_ESCAPE: return 0xff1b; case KeyEvent.VK_INSERT: return 0xff63; case KeyEvent.VK_DELETE: return 0xffff; case KeyEvent.VK_HOME: return 0xff50; case KeyEvent.VK_END: return 0xff57; case KeyEvent.VK_PAGE_UP: return 0xff55; case KeyEvent.VK_PAGE_DOWN: return 0xff56; case KeyEvent.VK_LEFT: return 0xff51; case KeyEvent.VK_UP: return 0xff52; case KeyEvent.VK_RIGHT: return 0xff53; case KeyEvent.VK_DOWN: return 0xff54; case KeyEvent.VK_F1: return 0xffbe; case KeyEvent.VK_F2: return 0xffbf; case KeyEvent.VK_F3: return 0xffc0; case KeyEvent.VK_F4: return 0xffc1; case KeyEvent.VK_F5: return 0xffc2; case KeyEvent.VK_F6: return 0xffc3; case KeyEvent.VK_F7: return 0xffc4; case KeyEvent.VK_F8: return 0xffc5; case KeyEvent.VK_F9: return 0xffc6; case KeyEvent.VK_F10: return 0xffc7; case KeyEvent.VK_F11: return 0xffc8; case KeyEvent.VK_F12: return 0xffc9; case KeyEvent.VK_SHIFT: return 0xffe1; case KeyEvent.VK_CONTROL: return 0xffe3; case KeyEvent.VK_META: return 0xffe7; case KeyEvent.VK_ALT: return 0xffe9; case KeyEvent.VK_ALT_GRAPH: return 0xffea; case KeyEvent.VK_BACK_QUOTE: return 0x0060; } return key; }
Example 17
Source File: ReflectCompletionDialog.java From jpexs-decompiler with GNU General Public License v3.0 | 4 votes |
private void jTxtItemKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTxtItemKeyPressed int i = jLstItems.getSelectedIndex(); switch (evt.getKeyCode()) { case KeyEvent.VK_ESCAPE: target.setCaretPosition(target.getSelectionEnd()); setVisible(false); return; case KeyEvent.VK_DOWN: i++; break; case KeyEvent.VK_UP: i--; break; case KeyEvent.VK_HOME: i = 0; break; case KeyEvent.VK_END: i = jLstItems.getModel().getSize() - 1; break; case KeyEvent.VK_PAGE_DOWN: i += jLstItems.getVisibleRowCount(); break; case KeyEvent.VK_PAGE_UP: i -= jLstItems.getVisibleRowCount(); break; } if (escapeChars.indexOf(evt.getKeyChar()) >= 0) { String result = getSelection(); char pressed = evt.getKeyChar(); // we need to just accept ENTER, and replace the tab with a single // space if (pressed != '\n') { result += (pressed == '\t') ? ' ' : pressed; } target.replaceSelection(result); setVisible(false); } else { // perform bounds checks for i if (i >= jLstItems.getModel().getSize()) { i = jLstItems.getModel().getSize() - 1; } if (i < 0) { i = 0; } jLstItems.setSelectedIndex(i); jLstItems.ensureIndexIsVisible(i); } }
Example 18
Source File: KeyToggler.java From Any-Angle-Pathfinding with The Unlicense | 4 votes |
@Override public void keyPressed(KeyEvent arg0) { switch(arg0.getKeyCode()) { case KeyEvent.VK_RIGHT : goRight(1, false); break; case KeyEvent.VK_LEFT : goLeft(1, false); break; case KeyEvent.VK_UP : goRight(1, true); break; case KeyEvent.VK_DOWN : goLeft(1, true); break; case KeyEvent.VK_PAGE_UP : goRight(10, false); break; case KeyEvent.VK_PAGE_DOWN : goLeft(10, false); break; case KeyEvent.VK_D : goRight(3, true); break; case KeyEvent.VK_A : goLeft(3, true); break; case KeyEvent.VK_W : goRight(5, true); break; case KeyEvent.VK_S : goLeft(5, true); break; // O: Go right one step + take screenshot, loops around case KeyEvent.VK_O : if (goRight(1, false)) takeSnapShot(); break; // P: Go right one step + take screenshot, stop at end case KeyEvent.VK_P : if (goRight(1, true)) takeSnapShot(); break; // L: Go right multiple steps + take screenshot, stop at end case KeyEvent.VK_L : if (goRight(13, true)) takeSnapShot(); break; // Esc: Close Window case KeyEvent.VK_ESCAPE : System.exit(0); break; } }
Example 19
Source File: JavaRecorderHook.java From marathonv5 with Apache License 2.0 | 4 votes |
public static String keyEventGetKeyText(int keycode) { if (keycode == KeyEvent.VK_TAB) { return "Tab"; } if (keycode == KeyEvent.VK_CONTROL) { return "Ctrl"; } if (keycode == KeyEvent.VK_ALT) { return "Alt"; } if (keycode == KeyEvent.VK_SHIFT) { return "Shift"; } if (keycode == KeyEvent.VK_META) { return "Meta"; } if (keycode == KeyEvent.VK_SPACE) { return "Space"; } if (keycode == KeyEvent.VK_BACK_SPACE) { return "Backspace"; } if (keycode == KeyEvent.VK_HOME) { return "Home"; } if (keycode == KeyEvent.VK_END) { return "End"; } if (keycode == KeyEvent.VK_DELETE) { return "Delete"; } if (keycode == KeyEvent.VK_PAGE_UP) { return "Pageup"; } if (keycode == KeyEvent.VK_PAGE_DOWN) { return "Pagedown"; } if (keycode == KeyEvent.VK_UP) { return "Up"; } if (keycode == KeyEvent.VK_DOWN) { return "Down"; } if (keycode == KeyEvent.VK_LEFT) { return "Left"; } if (keycode == KeyEvent.VK_RIGHT) { return "Right"; } if (keycode == KeyEvent.VK_ENTER) { return "Enter"; } return KeyEvent.getKeyText(keycode); }
Example 20
Source File: Popup.java From MeteoInfo with GNU Lesser General Public License v3.0 | 4 votes |
public synchronized void type(KeyEvent e) { if (!this.isVisible()) return; switch (e.getKeyCode()) { case KeyEvent.VK_ESCAPE: this.setVisible(false); break; case KeyEvent.VK_ENTER: case KeyEvent.VK_TAB: this.chooseSelected(); e.consume(); break; case KeyEvent.VK_SPACE: this.chooseSelected(); break; case KeyEvent.VK_PERIOD: this.chooseSelected(); break; case KeyEvent.VK_LEFT_PARENTHESIS: this.chooseSelected(); break; case KeyEvent.VK_UP: this.up(); e.consume(); break; case KeyEvent.VK_DOWN: this.down(); e.consume(); break; case KeyEvent.VK_PAGE_UP: this.pageUp(); e.consume(); break; case KeyEvent.VK_PAGE_DOWN: this.pageDown(); e.consume(); break; case KeyEvent.VK_BACK_SPACE: if (this.typed.isEmpty()){ this.setVisible(false); break; } this.typed = this.typed.substring(0, this.typed.length() - 1); this.data = filter(this.originalData, this.typed); this.list.setListData(this.data); this.list.setSelectedIndex(0); break; default: char c = e.getKeyChar(); if (Character.isJavaIdentifierPart(c)){ this.typed += c; this.data = filter(this.data, this.typed); this.list.setListData(this.data); this.list.setSelectedIndex(0); } break; } }