Java Code Examples for java.awt.event.KeyEvent#VK_0
The following examples show how to use
java.awt.event.KeyEvent#VK_0 .
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: CalculadoraTela.java From dctb-utfpr-2018-1 with Apache License 2.0 | 6 votes |
public void operarComTeclaDigitada(java.awt.event.KeyEvent evt) { // Se foi digitado uma das teclas a seguir if ((evt.getKeyCode() == KeyEvent.VK_0) || (evt.getKeyCode() == KeyEvent.VK_1) || (evt.getKeyCode() == KeyEvent.VK_2) || (evt.getKeyCode() == KeyEvent.VK_3) || (evt.getKeyCode() == KeyEvent.VK_4) || (evt.getKeyCode() == KeyEvent.VK_5) || (evt.getKeyCode() == KeyEvent.VK_6) || (evt.getKeyCode() == KeyEvent.VK_7) || (evt.getKeyCode() == KeyEvent.VK_8) || (evt.getKeyCode() == KeyEvent.VK_9) || (evt.getKeyCode() == KeyEvent.VK_ADD) || (evt.getKeyCode() == KeyEvent.VK_SUBTRACT) || (evt.getKeyCode() == KeyEvent.VK_DIVIDE) || (evt.getKeyCode() == KeyEvent.VK_MULTIPLY) || (evt.getKeyCode() == KeyEvent.VK_EQUALS)) { this.operarConformeEstado("" + evt.getKeyChar()); } else if (evt.getKeyCode() == KeyEvent.VK_L) { this.operarConformeEstado("Limpar"); } }
Example 2
Source File: MainFrame.java From uima-uimaj with Apache License 2.0 | 6 votes |
/** * Gets the mnemonic. * * @param i the i * @return the mnemonic */ private static final int getMnemonic(int i) { switch (i) { case 1: return KeyEvent.VK_1; case 2: return KeyEvent.VK_2; case 3: return KeyEvent.VK_3; case 4: return KeyEvent.VK_4; case 5: return KeyEvent.VK_5; case 6: return KeyEvent.VK_6; case 7: return KeyEvent.VK_7; case 8: return KeyEvent.VK_8; case 9: return KeyEvent.VK_9; default: return KeyEvent.VK_0; } }
Example 3
Source File: BookmarkKeyChooser.java From netbeans with Apache License 2.0 | 6 votes |
@Override public void keyPressed(KeyEvent e) { int keyCode = e.getKeyCode(); char ch = 0; if (KeyEvent.VK_0 <= keyCode && keyCode <= KeyEvent.VK_9) { ch = (char) ((keyCode - KeyEvent.VK_0) + '0'); } else if (KeyEvent.VK_A <= keyCode && keyCode <= KeyEvent.VK_Z) { ch = (char) ((keyCode - KeyEvent.VK_A) + 'A'); } if (ch != 0) { BookmarkInfo bookmark = key2bookmark.get(ch); if (bookmark != null) { result = bookmark; dispose(); } } }
Example 4
Source File: InsertRecordDialog.java From netbeans with Apache License 2.0 | 6 votes |
private void processKeyEvents(KeyEvent e) { KeyStroke copy = KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK, false); KeyStroke paste = KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.CTRL_MASK, false); KeyStroke tab = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0); if (KeyStroke.getKeyStrokeForEvent(e).equals(copy)) { copy(); } else if (KeyStroke.getKeyStrokeForEvent(e).equals(paste)) { paste(); } if (e.isControlDown() && e.getKeyCode() == KeyEvent.VK_DELETE) { insertRecordTableUI.removeRows(); } else if (e.getKeyCode() == KeyEvent.VK_ENTER) { setFocusable(false); } else if (e.isControlDown() && e.getKeyChar() == KeyEvent.VK_0) { control0Event(); e.consume(); } else if (e.isControlDown() && e.getKeyChar() == KeyEvent.VK_1) { control1Event(); e.consume(); } else if (KeyStroke.getKeyStrokeForEvent(e).equals(tab)) { } }
Example 5
Source File: ActivateToolWindowAction.java From consulo with Apache License 2.0 | 6 votes |
/** * @return mnemonic for action if it has Alt+digit/Meta+digit shortcut. * Otherwise the method returns <code>-1</code>. Meta mask is OK for * Mac OS X user, because Alt+digit types strange characters into the * editor. */ public static int getMnemonicForToolWindow(String id) { Keymap activeKeymap = KeymapManager.getInstance().getActiveKeymap(); Shortcut[] shortcuts = activeKeymap.getShortcuts(getActionIdForToolWindow(id)); for (Shortcut shortcut : shortcuts) { if (shortcut instanceof KeyboardShortcut) { KeyStroke keyStroke = ((KeyboardShortcut)shortcut).getFirstKeyStroke(); int modifiers = keyStroke.getModifiers(); if (modifiers == (InputEvent.ALT_DOWN_MASK | InputEvent.ALT_MASK) || modifiers == InputEvent.ALT_MASK || modifiers == InputEvent.ALT_DOWN_MASK || modifiers == (InputEvent.META_DOWN_MASK | InputEvent.META_MASK) || modifiers == InputEvent.META_MASK || modifiers == InputEvent.META_DOWN_MASK) { int keyCode = keyStroke.getKeyCode(); if (KeyEvent.VK_0 <= keyCode && keyCode <= KeyEvent.VK_9) { char c = (char)('0' + keyCode - KeyEvent.VK_0); return (int)c; } } } } return -1; }
Example 6
Source File: SmoothMoves.java From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Toggles various rendering flags */ public void keyPressed(KeyEvent ke) { int keyCode = ke.getKeyCode(); if (keyCode == KeyEvent.VK_B) { // B: Motion blur - displays trail of ghost images motionBlur = !motionBlur; } else if (keyCode == KeyEvent.VK_A) { // A: Antialiasing - Displays soft edges around graphics useAA = !useAA; createAnimationImage(); } else if (keyCode == KeyEvent.VK_C) { // C: Color - Toggles rectangle color between dark and light colors alterColor = !alterColor; createAnimationImage(); } else if (keyCode == KeyEvent.VK_I) { // I: Image - Toggles use of image or filled rectangle to show how // straight edges affect animation perception useImage = !useImage; createAnimationImage(); } else if (keyCode == KeyEvent.VK_UP) { // Up Arrow: Speed - Speeds up frame rate changeResolution(true); } else if (keyCode == KeyEvent.VK_DOWN) { // Down Arrow: Speed - Slows down frame rate changeResolution(false); } else if (keyCode == KeyEvent.VK_L) { // L: Linearity: Toggles linear/nonlinear motion linear = !linear; } else if (keyCode >= KeyEvent.VK_1 && keyCode <= KeyEvent.VK_9) { // 0-9: Blur size: Toggles size of ghost trail for motion blur blurSize = keyCode - KeyEvent.VK_0; prevMoveX = prevMoveY = null; } }
Example 7
Source File: Canvas.java From Logisim with GNU General Public License v3.0 | 5 votes |
@Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_F5) { proj.getSimulator().requestReset(); proj.getSimulator().setIsRunning(true); } else if ((e.getKeyCode() == KeyEvent.VK_0 || e.getKeyCode() == KeyEvent.VK_NUMPAD0) && e.isControlDown()) { autoZoomCenter(); } else { Tool tool = proj.getTool(); if (tool != null) tool.keyPressed(Canvas.this, e); } }
Example 8
Source File: KeyShortcutTest.java From netbeans-mmd-plugin with Apache License 2.0 | 5 votes |
@Test public void testDoesShortcutConflict() { final KeyShortcut shortcut = new KeyShortcut("some", KeyEvent.VK_0, KeyEvent.SHIFT_MASK); assertFalse(shortcut.doesConflictWith(null)); assertFalse(shortcut.doesConflictWith(KeyStroke.getKeyStroke(KeyEvent.VK_0, KeyEvent.CTRL_MASK))); assertFalse(shortcut.doesConflictWith(KeyStroke.getKeyStroke(KeyEvent.VK_1, KeyEvent.SHIFT_MASK | KeyEvent.CTRL_MASK))); assertFalse(shortcut.doesConflictWith(KeyStroke.getKeyStroke(KeyEvent.VK_0, KeyEvent.CTRL_DOWN_MASK))); assertFalse(shortcut.doesConflictWith(KeyStroke.getKeyStroke(KeyEvent.VK_1, KeyEvent.SHIFT_DOWN_MASK | KeyEvent.CTRL_DOWN_MASK))); assertTrue(shortcut.doesConflictWith(KeyStroke.getKeyStroke(KeyEvent.VK_0, KeyEvent.SHIFT_MASK | KeyEvent.CTRL_MASK))); assertTrue(shortcut.doesConflictWith(KeyStroke.getKeyStroke(KeyEvent.VK_0, KeyEvent.SHIFT_MASK))); assertTrue(shortcut.doesConflictWith(KeyStroke.getKeyStroke(KeyEvent.VK_0, KeyEvent.SHIFT_DOWN_MASK | KeyEvent.CTRL_DOWN_MASK))); assertTrue(shortcut.doesConflictWith(KeyStroke.getKeyStroke(KeyEvent.VK_0, KeyEvent.SHIFT_DOWN_MASK))); }
Example 9
Source File: IPV4Field.java From lippen-network-tool with Apache License 2.0 | 5 votes |
public void keyPressed(KeyEvent e) { JTextComponent field = (JTextComponent) e.getComponent(); int keyCode = e.getKeyCode(); char keyChar = e.getKeyChar(); String text = field.getText(); String selText = field.getSelectedText(); int caretPos = field.getCaretPosition(); int textLength = text.length(); if ((keyCode == KeyEvent.VK_LEFT) && (caretPos == 0) && (selText == null)) { field.firePropertyChange("Left", 0, 1); } else if (((keyCode == KeyEvent.VK_RIGHT) && (caretPos == textLength) && (selText == null)) || ((keyChar == '.') && (!text.isEmpty()) && (selText == null))) { field.firePropertyChange("Right", 0, 1); } else if ((keyCode == KeyEvent.VK_BACK_SPACE) && (caretPos == 0) && (selText == null)) { field.firePropertyChange("BackSpace", 0, 1); } else if ((keyCode == KeyEvent.VK_DELETE) && (caretPos == textLength) && (selText == null)) { field.firePropertyChange("Delete", 0, 1); } else if (keyCode == KeyEvent.VK_HOME) { IPV4Field.this.ipFields[0].unSelectAllWhenFocusGained(); IPV4Field.this.ipFields[0].requestFocus(); IPV4Field.this.ipFields[0].setCaretPosition(0); } else if (keyCode == KeyEvent.VK_END) { int last = IPV4Field.this.ipFields.length - 1; textLength = IPV4Field.this.ipFields[last].getText() .length(); IPV4Field.this.ipFields[last] .unSelectAllWhenFocusGained(); IPV4Field.this.ipFields[last].requestFocus(); IPV4Field.this.ipFields[last] .setCaretPosition(textLength); } else if ((keyCode == KeyEvent.VK_0 || keyCode == KeyEvent.VK_NUMPAD0) && (caretPos == 0 || (text != null && text.equals(selText)))) { field.firePropertyChange("Right", 0, 1); } else if (("0123456789".indexOf(keyChar) >= 0)) { if (selText == null) { int ipInt = (text.length() == 0 ? 0 : Integer .parseInt(text)); if (ipInt > 25) { field.firePropertyChange("Right", 0, 1); } } else { if (field.getSelectionStart() == 2 && field.getSelectionEnd() == 3) { field.firePropertyChange("Right", 0, 1); } } } }
Example 10
Source File: KeyRemappingConfig.java From plugins with GNU General Public License v3.0 | 5 votes |
@ConfigItem( position = 16, keyName = "f10", name = "F10", description = "The key which will replace {F10}." ) default ModifierlessKeybind f10() { return new ModifierlessKeybind(KeyEvent.VK_0, 0); }
Example 11
Source File: KeyRemappingConfig.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
@ConfigItem( position = 16, keyName = "f10", name = "F10", description = "The key which will replace {F10}.", section = fKeySection ) default ModifierlessKeybind f10() { return new ModifierlessKeybind(KeyEvent.VK_0, 0); }
Example 12
Source File: NumberDocumentFilter.java From WIFIADB with Apache License 2.0 | 5 votes |
@Override public void keyTyped(KeyEvent e) { final int key = e.getKeyChar(); if(key < KeyEvent.VK_0 || key > KeyEvent.VK_9){ e.consume(); } }
Example 13
Source File: CreateWorkDialog.java From workcraft with MIT License | 4 votes |
private int getKeyCode(int index) { if (index < 9) return KeyEvent.VK_1 + index; if (index == 9) return KeyEvent.VK_0; return KeyEvent.VK_A + index - 10; }
Example 14
Source File: GameKeyHandler.java From stendhal with GNU General Public License v2.0 | 4 votes |
@Override public void keyPressed(final KeyEvent e) { final int keyCode = e.getKeyCode(); final boolean doublePress = isDoublePress(keyCode); /* Ignore if the key is already pressed down. */ if (!client.keyIsPressed(keyCode)) { /* Add keyCode to pressedStateKeys list. */ client.onKeyPressed(keyCode); if (e.isShiftDown()) { /* * We are going to use shift to move to previous/next line of text * with arrows so we just ignore the keys if shift is pressed. */ return; } switch (keyCode) { case KeyEvent.VK_R: if (e.isControlDown()) { /* * Ctrl+R Remove text bubbles */ screen.clearTexts(); } break; case KeyEvent.VK_LEFT: case KeyEvent.VK_RIGHT: case KeyEvent.VK_UP: case KeyEvent.VK_DOWN: case KeyEvent.VK_KP_LEFT: case KeyEvent.VK_KP_RIGHT: case KeyEvent.VK_KP_UP: case KeyEvent.VK_KP_DOWN: /* * Ctrl means face, otherwise move. Alt turns on auto-walk. */ final Direction direction = keyCodeToDirection(e.getKeyCode()); /* Check if the player is currently using auto-walk or the Alt * key is pressed. */ User user = User.get(); if ((user.getRPObject().has(AUTOWALK) || ("true".equals(WtWindowManager.getInstance().getProperty(DOUBLE_TAP_AUTOWALK_PROPERTY, "false")) && doublePress))) { /* Face direction pressed and toggle auto-walk. */ this.processAutoWalk(direction, user); } else { if (e.isAltGraphDown()) { if (System.currentTimeMillis() - lastAction > 1000) { final EntityView<?> view = screen.getEntityViewAt( user.getX() + direction.getdx(), user.getY() + direction.getdy()); if (view != null) { final IEntity entity = view.getEntity(); if (!entity.equals(user)) { view.onAction(); lastAction = System.currentTimeMillis(); } } } } this.processDirectionPress(direction, e.isControlDown()); } break; case KeyEvent.VK_0: case KeyEvent.VK_1: case KeyEvent.VK_2: case KeyEvent.VK_3: case KeyEvent.VK_4: case KeyEvent.VK_5: case KeyEvent.VK_6: case KeyEvent.VK_7: case KeyEvent.VK_8: case KeyEvent.VK_9: switchToSpellCastingState(e); break; } } }
Example 15
Source File: KeyCodeToChar.java From Repeat with Apache License 2.0 | 4 votes |
private static String getNonAlphaCharWithShift(int code) { switch (code) { case KeyEvent.VK_BACK_QUOTE: return "~"; case KeyEvent.VK_1: return "!"; case KeyEvent.VK_2: return "@"; case KeyEvent.VK_3: return "#"; case KeyEvent.VK_4: return "$"; case KeyEvent.VK_5: return "%"; case KeyEvent.VK_6: return "^"; case KeyEvent.VK_7: return "&"; case KeyEvent.VK_8: return "*"; case KeyEvent.VK_9: return "("; case KeyEvent.VK_0: return ")"; case KeyEvent.VK_MINUS: return "_"; case KeyEvent.VK_EQUALS: return "+"; case KeyEvent.VK_OPEN_BRACKET: return "{"; case KeyEvent.VK_CLOSE_BRACKET: return "}"; case KeyEvent.VK_SEMICOLON: return ":"; case KeyEvent.VK_QUOTE: return "\""; case KeyEvent.VK_BACK_SLASH: return "|"; case KeyEvent.VK_COMMA: return "<"; case KeyEvent.VK_PERIOD: return ">"; case KeyEvent.VK_SLASH: return "?"; case KeyEvent.VK_TAB: return "\t"; case KeyEvent.VK_ENTER: return "\n"; case KeyEvent.VK_SPACE: return " "; default: return ""; } }
Example 16
Source File: KeyCodeToChar.java From Repeat with Apache License 2.0 | 4 votes |
private static String getNonAlphaCharWithoutShift(int code) { switch (code) { case KeyEvent.VK_BACK_QUOTE: return "`"; case KeyEvent.VK_1: return "1"; case KeyEvent.VK_2: return "2"; case KeyEvent.VK_3: return "3"; case KeyEvent.VK_4: return "4"; case KeyEvent.VK_5: return "5"; case KeyEvent.VK_6: return "6"; case KeyEvent.VK_7: return "7"; case KeyEvent.VK_8: return "8"; case KeyEvent.VK_9: return "9"; case KeyEvent.VK_0: return "0"; case KeyEvent.VK_MINUS: return "-"; case KeyEvent.VK_EQUALS: return "="; case KeyEvent.VK_OPEN_BRACKET: return "["; case KeyEvent.VK_CLOSE_BRACKET: return "]"; case KeyEvent.VK_SEMICOLON: return ";"; case KeyEvent.VK_QUOTE: return "'"; case KeyEvent.VK_BACK_SLASH: return "\\"; case KeyEvent.VK_COMMA: return ","; case KeyEvent.VK_PERIOD: return "."; case KeyEvent.VK_SLASH: return "/"; case KeyEvent.VK_TAB: return "\t"; case KeyEvent.VK_ENTER: return "\n"; case KeyEvent.VK_SPACE: return " "; default: return ""; } }
Example 17
Source File: Robot.java From xnx3 with Apache License 2.0 | 4 votes |
/** * 将字符型转换为按键码,可直接使用 {@link #press(int)}调用 * @param key 字符型文字,包含 0~9 a~z . * @return 按键码 */ public int StringToKey(String key){ switch (key) { case "a": return KeyEvent.VK_A; case "b": return KeyEvent.VK_B; case "c": return KeyEvent.VK_C; case "d": return KeyEvent.VK_D; case "e": return KeyEvent.VK_E; case "f": return KeyEvent.VK_F; case "g": return KeyEvent.VK_G; case "h": return KeyEvent.VK_H; case "i": return KeyEvent.VK_I; case "j": return KeyEvent.VK_J; case "k": return KeyEvent.VK_K; case "l": return KeyEvent.VK_L; case "m": return KeyEvent.VK_M; case "n": return KeyEvent.VK_N; case "o": return KeyEvent.VK_O; case "p": return KeyEvent.VK_P; case "q": return KeyEvent.VK_Q; case "r": return KeyEvent.VK_R; case "s": return KeyEvent.VK_S; case "t": return KeyEvent.VK_T; case "u": return KeyEvent.VK_U; case "v": return KeyEvent.VK_V; case "w": return KeyEvent.VK_W; case "x": return KeyEvent.VK_X; case "y": return KeyEvent.VK_Y; case "z": return KeyEvent.VK_Z; case "0": return KeyEvent.VK_0; case "1": return KeyEvent.VK_1; case "2": return KeyEvent.VK_2; case "3": return KeyEvent.VK_3; case "4": return KeyEvent.VK_4; case "5": return KeyEvent.VK_5; case "6": return KeyEvent.VK_6; case "7": return KeyEvent.VK_7; case "8": return KeyEvent.VK_8; case "9": return KeyEvent.VK_9; case ".": return KeyEvent.VK_PERIOD; default: break; } return 0; }
Example 18
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 19
Source File: Spectrum.java From wandora with GNU General Public License v3.0 | 4 votes |
private int key(KeyEvent e) { int c = e.getKeyCode(); int a = e.getKeyChar(); int i = "[AQ10P\n ZSW29OL]XDE38IKMCFR47UJNVGT56YHB".indexOf((char) c); if (i >= 0) { simple: { int s = 0; if (c >= KeyEvent.VK_0 && c <= KeyEvent.VK_9) { if (c != (int) a) { break simple; } if (e.isAltDown()) { s = 0100; } } return i | s; } } if (a != '\0') { i = "\t\0\0!_\"\0\0:\0\0@);=\0\0\0\0#(\0+.?\0<$'\0-,/\0>%&\0^*".indexOf(a); if (i >= 0) { return i | 0200; } } switch (c) { case KeyEvent.VK_INSERT: case KeyEvent.VK_ESCAPE: return 0103; case KeyEvent.VK_KP_LEFT: case KeyEvent.VK_LEFT: i = 0; break; case KeyEvent.VK_KP_DOWN: case KeyEvent.VK_DOWN: i = 3; break; case KeyEvent.VK_KP_UP: case KeyEvent.VK_UP: i = 2; break; case KeyEvent.VK_KP_RIGHT: case KeyEvent.VK_RIGHT: i = 1; break; case KeyEvent.VK_BACK_SPACE: return 0104; case KeyEvent.VK_SHIFT: return 01000; case KeyEvent.VK_CONTROL: kempston |= 0x10; /* fall */ case KeyEvent.VK_ALT: return 02000; default: return -1; } kempston |= 1 << (i ^ 1); return e.isAltDown() ? arrowsDefault[i] : arrows[i]; }
Example 20
Source File: MITextEditorPane.java From MeteoInfo with GNU Lesser General Public License v3.0 | 4 votes |
private synchronized void type(KeyEvent e) { if (this.popup.isVisible()) { if (e.getID() == KeyEvent.KEY_PRESSED) { this.popup.type(e); } return; } switch (e.getKeyCode()) { case (KeyEvent.VK_PERIOD): showPopup(); e.consume(); break; case (KeyEvent.VK_SPACE): String command = getCurrentText(); Matcher match = FROM_PACKAGE_IMPORT.matcher(command); if (match.matches()) { showPopup(); } e.consume(); break; case (KeyEvent.VK_9): if (e.isShiftDown()) { showTip(); } e.consume(); break; case (KeyEvent.VK_0): if (e.isShiftDown()) { tip.setVisible(false); } e.consume(); break; case (KeyEvent.VK_LEFT): case (KeyEvent.VK_BACK_SPACE): case (KeyEvent.VK_DELETE): if (tip.isVisible()) { tip.setVisible(false); } } }