Java Code Examples for java.awt.event.KeyEvent#VK_NUMPAD0
The following examples show how to use
java.awt.event.KeyEvent#VK_NUMPAD0 .
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: 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 2
Source File: AppearanceCanvas.java From Logisim with GNU General Public License v3.0 | 5 votes |
@Override public void keyPressed(KeyEvent arg0) { if ((arg0.getKeyCode() == KeyEvent.VK_0 || arg0.getKeyCode() == KeyEvent.VK_NUMPAD0) && arg0.isControlDown()) { autoZoomCenter(); } }
Example 3
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 4
Source File: KeyCodeToChar.java From Repeat with Apache License 2.0 | 5 votes |
private static String getCharFromNumpadCode(int code, KeyboardState state) { if (!state.isNumslockLocked()) { return ""; } switch (code) { case KeyEvent.VK_NUMPAD0: return "0"; case KeyEvent.VK_NUMPAD1: return "1"; case KeyEvent.VK_NUMPAD2: return "2"; case KeyEvent.VK_NUMPAD3: return "3"; case KeyEvent.VK_NUMPAD4: return "4"; case KeyEvent.VK_NUMPAD5: return "5"; case KeyEvent.VK_NUMPAD6: return "6"; case KeyEvent.VK_NUMPAD7: return "7"; case KeyEvent.VK_NUMPAD8: return "8"; case KeyEvent.VK_NUMPAD9: return "9"; case KeyEvent.VK_PLUS: return "+"; case KeyEvent.VK_MULTIPLY: return "*"; default: return ""; } }
Example 5
Source File: RobotNetworkControlMessageHandler.java From Dayon with GNU General Public License v3.0 | 5 votes |
/** * Unicode characters are typed in decimal on Windows รค => 228 */ private void typeWindowsUnicode(int keyCode) { robot.keyPress(KeyEvent.VK_ALT); // simulate a numpad key press for each digit for (int i = 3; i >= 0; --i) { int code = keyCode / (int) (Math.pow(10, i)) % 10 + KeyEvent.VK_NUMPAD0; robot.keyPress(code); robot.keyRelease(code); } robot.keyRelease(KeyEvent.VK_ALT); }
Example 6
Source File: MacKeymapUtil.java From consulo with Apache License 2.0 | 4 votes |
public static String getKeyText(int code) { switch (code) { case KeyEvent.VK_BACK_SPACE: return BACKSPACE; case KeyEvent.VK_ESCAPE: return ESCAPE; case KeyEvent.VK_CAPS_LOCK: return CAPS_LOCK; case KeyEvent.VK_TAB: return TAB; case KeyEvent.VK_SPACE: return SPACE; case KeyEvent.VK_DELETE: return DELETE; case KeyEvent.VK_HOME: return HOME; case KeyEvent.VK_END: return END; case KeyEvent.VK_PAGE_UP: return PAGE_UP; case KeyEvent.VK_PAGE_DOWN: return PAGE_DOWN; case KeyEvent.VK_UP: return UP; case KeyEvent.VK_DOWN: return DOWN; case KeyEvent.VK_LEFT: return LEFT; case KeyEvent.VK_RIGHT: return RIGHT; case KeyEvent.VK_NUM_LOCK: return NUMBER_LOCK; case KeyEvent.VK_ENTER: return RETURN; case KeyEvent.VK_BACK_QUOTE: return "`"; case KeyEvent.VK_NUMBER_SIGN: return NUM_PAD; case KeyEvent.VK_MULTIPLY: return NUM_PAD + " *"; case KeyEvent.VK_ADD: return "+"; case KeyEvent.VK_SEPARATOR: return ","; case KeyEvent.VK_SUBTRACT: return "-"; case KeyEvent.VK_DECIMAL: return "."; case KeyEvent.VK_DIVIDE: return "/"; case KeyEvent.VK_NUMPAD0: return "0"; case KeyEvent.VK_NUMPAD1: return "1"; case KeyEvent.VK_NUMPAD2: return "2"; case KeyEvent.VK_NUMPAD3: return "3"; case KeyEvent.VK_NUMPAD4: return "4"; case KeyEvent.VK_NUMPAD5: return "5"; case KeyEvent.VK_NUMPAD6: return "6"; case KeyEvent.VK_NUMPAD7: return "7"; case KeyEvent.VK_NUMPAD8: return "8"; case KeyEvent.VK_NUMPAD9: return "9"; case KeyEvent.VK_SLASH: return "/"; case KeyEvent.VK_BACK_SLASH: return "\\"; case KeyEvent.VK_PERIOD: return "."; case KeyEvent.VK_SEMICOLON: return ";"; case KeyEvent.VK_CLOSE_BRACKET: return "]"; case KeyEvent.VK_OPEN_BRACKET: return "["; case KeyEvent.VK_EQUALS: return "="; case KeyEvent.VK_MINUS: return "-"; case KeyEvent.VK_PLUS: return "+"; case 0: return "fn"; } return KeyEvent.getKeyText(code); }