Java Code Examples for java.awt.event.KeyEvent#getKeyModifiersText()
The following examples show how to use
java.awt.event.KeyEvent#getKeyModifiersText() .
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: MenuItemLayoutHelper.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@SuppressWarnings("deprecation") private String getAccText(String acceleratorDelimiter) { String accText = ""; KeyStroke accelerator = mi.getAccelerator(); if (accelerator != null) { int modifiers = accelerator.getModifiers(); if (modifiers > 0) { accText = KeyEvent.getKeyModifiersText(modifiers); accText += acceleratorDelimiter; } int keyCode = accelerator.getKeyCode(); if (keyCode != 0) { accText += KeyEvent.getKeyText(keyCode); } else { accText += accelerator.getKeyChar(); } } return accText; }
Example 2
Source File: MenuItemLayoutHelper.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
private String getAccText(String acceleratorDelimiter) { String accText = ""; KeyStroke accelerator = mi.getAccelerator(); if (accelerator != null) { int modifiers = accelerator.getModifiers(); if (modifiers > 0) { accText = KeyEvent.getKeyModifiersText(modifiers); accText += acceleratorDelimiter; } int keyCode = accelerator.getKeyCode(); if (keyCode != 0) { accText += KeyEvent.getKeyText(keyCode); } else { accText += accelerator.getKeyChar(); } } return accText; }
Example 3
Source File: MenuItemLayoutHelper.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
private String getAccText(String acceleratorDelimiter) { String accText = ""; KeyStroke accelerator = mi.getAccelerator(); if (accelerator != null) { int modifiers = accelerator.getModifiers(); if (modifiers > 0) { accText = KeyEvent.getKeyModifiersText(modifiers); accText += acceleratorDelimiter; } int keyCode = accelerator.getKeyCode(); if (keyCode != 0) { accText += KeyEvent.getKeyText(keyCode); } else { accText += accelerator.getKeyChar(); } } return accText; }
Example 4
Source File: MenuItemLayoutHelper.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
private String getAccText(String acceleratorDelimiter) { String accText = ""; KeyStroke accelerator = mi.getAccelerator(); if (accelerator != null) { int modifiers = accelerator.getModifiers(); if (modifiers > 0) { accText = KeyEvent.getKeyModifiersText(modifiers); accText += acceleratorDelimiter; } int keyCode = accelerator.getKeyCode(); if (keyCode != 0) { accText += KeyEvent.getKeyText(keyCode); } else { accText += accelerator.getKeyChar(); } } return accText; }
Example 5
Source File: MenuItemLayoutHelper.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
private String getAccText(String acceleratorDelimiter) { String accText = ""; KeyStroke accelerator = mi.getAccelerator(); if (accelerator != null) { int modifiers = accelerator.getModifiers(); if (modifiers > 0) { accText = KeyEvent.getKeyModifiersText(modifiers); accText += acceleratorDelimiter; } int keyCode = accelerator.getKeyCode(); if (keyCode != 0) { accText += KeyEvent.getKeyText(keyCode); } else { accText += accelerator.getKeyChar(); } } return accText; }
Example 6
Source File: MenuItemLayoutHelper.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
private String getAccText(String acceleratorDelimiter) { String accText = ""; KeyStroke accelerator = mi.getAccelerator(); if (accelerator != null) { int modifiers = accelerator.getModifiers(); if (modifiers > 0) { accText = KeyEvent.getKeyModifiersText(modifiers); accText += acceleratorDelimiter; } int keyCode = accelerator.getKeyCode(); if (keyCode != 0) { accText += KeyEvent.getKeyText(keyCode); } else { accText += accelerator.getKeyChar(); } } return accText; }
Example 7
Source File: Catbert.java From sagetv with Apache License 2.0 | 5 votes |
public static String getStringFromKeystroke(int code, int mods) { String str = ""; if (mods != 0) str += KeyEvent.getKeyModifiersText(mods); if (code != KeyEvent.VK_SHIFT && code != KeyEvent.VK_ALT && code != KeyEvent.VK_CONTROL) { if (mods != 0) str += "+"; str += KeyEvent.getKeyText(code); } return str; }
Example 8
Source File: MenuShortcut.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
/** * Returns an internationalized description of the MenuShortcut. * @return a string representation of this MenuShortcut. * @since JDK1.1 */ public String toString() { int modifiers = 0; if (!GraphicsEnvironment.isHeadless()) { modifiers = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); } if (usesShiftModifier()) { modifiers |= Event.SHIFT_MASK; } return KeyEvent.getKeyModifiersText(modifiers) + "+" + KeyEvent.getKeyText(key); }
Example 9
Source File: MenuShortcut.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Returns an internationalized description of the MenuShortcut. * @return a string representation of this MenuShortcut. * @since JDK1.1 */ public String toString() { int modifiers = 0; if (!GraphicsEnvironment.isHeadless()) { modifiers = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); } if (usesShiftModifier()) { modifiers |= Event.SHIFT_MASK; } return KeyEvent.getKeyModifiersText(modifiers) + "+" + KeyEvent.getKeyText(key); }
Example 10
Source File: ActionsSupport.java From visualvm with GNU General Public License v2.0 | 5 votes |
public static String keyAcceleratorString(KeyStroke keyStroke) { if (keyStroke == null || NO_KEYSTROKE.equals(keyStroke)) return null; String keyText = KeyEvent.getKeyText(keyStroke.getKeyCode()); int modifiers = keyStroke.getModifiers(); if (modifiers == 0) return keyText; if (ACC_DELIMITER == null) { ACC_DELIMITER = UIManager.getString("MenuItem.acceleratorDelimiter"); // NOI18N if (ACC_DELIMITER == null) ACC_DELIMITER = "+"; // NOI18N // Note: NetBeans default, Swing uses '-' by default } return KeyEvent.getKeyModifiersText(modifiers) + ACC_DELIMITER + keyText; }
Example 11
Source File: MenuShortcut.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
/** * Returns an internationalized description of the MenuShortcut. * @return a string representation of this MenuShortcut. * @since JDK1.1 */ public String toString() { int modifiers = 0; if (!GraphicsEnvironment.isHeadless()) { modifiers = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); } if (usesShiftModifier()) { modifiers |= Event.SHIFT_MASK; } return KeyEvent.getKeyModifiersText(modifiers) + "+" + KeyEvent.getKeyText(key); }
Example 12
Source File: NbKeymap.java From netbeans with Apache License 2.0 | 5 votes |
private static String getKeyText (KeyStroke keyStroke) { if (keyStroke == null) return ""; String modifText = KeyEvent.getKeyModifiersText (keyStroke.getModifiers ()); if ("".equals (modifText)) return KeyEvent.getKeyText (keyStroke.getKeyCode ()); return modifText + "+" + // NOI18N KeyEvent.getKeyText (keyStroke.getKeyCode ()); }
Example 13
Source File: MenuShortcut.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Returns an internationalized description of the MenuShortcut. * @return a string representation of this MenuShortcut. * @since 1.1 */ @SuppressWarnings("deprecation") public String toString() { int modifiers = 0; if (!GraphicsEnvironment.isHeadless()) { modifiers = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); } if (usesShiftModifier()) { modifiers |= Event.SHIFT_MASK; } return KeyEvent.getKeyModifiersText(modifiers) + "+" + KeyEvent.getKeyText(key); }
Example 14
Source File: MenuShortcut.java From jdk-1.7-annotated with Apache License 2.0 | 5 votes |
/** * Returns an internationalized description of the MenuShortcut. * @return a string representation of this MenuShortcut. * @since JDK1.1 */ public String toString() { int modifiers = 0; if (!GraphicsEnvironment.isHeadless()) { modifiers = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); } if (usesShiftModifier()) { modifiers |= Event.SHIFT_MASK; } return KeyEvent.getKeyModifiersText(modifiers) + "+" + KeyEvent.getKeyText(key); }
Example 15
Source File: Key.java From SikuliX1 with MIT License | 5 votes |
/** * INTERNAL USE ONLY * * @param code keycode * @param mod modifier * @return readable key text */ public static String convertKeyToText(int code, int mod) { String txtMod = KeyEvent.getKeyModifiersText(mod); String txtCode = KeyEvent.getKeyText(code); String ret; if (code == KeyEvent.VK_ALT || code == KeyEvent.VK_CONTROL || code == KeyEvent.VK_SHIFT) { ret = txtMod; } else { ret = txtMod + " " + txtCode; } return ret; }
Example 16
Source File: MenuShortcut.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Returns an internationalized description of the MenuShortcut. * @return a string representation of this MenuShortcut. * @since JDK1.1 */ public String toString() { int modifiers = 0; if (!GraphicsEnvironment.isHeadless()) { modifiers = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); } if (usesShiftModifier()) { modifiers |= Event.SHIFT_MASK; } return KeyEvent.getKeyModifiersText(modifiers) + "+" + KeyEvent.getKeyText(key); }
Example 17
Source File: MenuShortcut.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
/** * Returns an internationalized description of the MenuShortcut. * @return a string representation of this MenuShortcut. * @since JDK1.1 */ public String toString() { int modifiers = 0; if (!GraphicsEnvironment.isHeadless()) { modifiers = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); } if (usesShiftModifier()) { modifiers |= Event.SHIFT_MASK; } return KeyEvent.getKeyModifiersText(modifiers) + "+" + KeyEvent.getKeyText(key); }
Example 18
Source File: MenuShortcut.java From Java8CN with Apache License 2.0 | 5 votes |
/** * Returns an internationalized description of the MenuShortcut. * @return a string representation of this MenuShortcut. * @since JDK1.1 */ public String toString() { int modifiers = 0; if (!GraphicsEnvironment.isHeadless()) { modifiers = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); } if (usesShiftModifier()) { modifiers |= Event.SHIFT_MASK; } return KeyEvent.getKeyModifiersText(modifiers) + "+" + KeyEvent.getKeyText(key); }
Example 19
Source File: DefaultKeyboardHandler.java From tn5250j with GNU General Public License v2.0 | 4 votes |
protected void displayInfo(KeyEvent e, String s) { String charString, keyCodeString, modString, tmpString, isString; char c = e.getKeyChar(); int keyCode = e.getKeyCode(); int modifiers = e.getModifiers(); if (Character.isISOControl(c)) { charString = "key character = " + "(an unprintable control character)"; } else { charString = "key character = '" + c + "'"; } keyCodeString = "key code = " + keyCode + " (" + KeyEvent.getKeyText(keyCode) + ")"; if (keyCode == KeyEvent.VK_PREVIOUS_CANDIDATE) { keyCodeString += " previous candidate "; } if (keyCode == KeyEvent.VK_DEAD_ABOVEDOT || keyCode == KeyEvent.VK_DEAD_ABOVERING || keyCode == KeyEvent.VK_DEAD_ACUTE || keyCode == KeyEvent.VK_DEAD_BREVE || keyCode == KeyEvent.VK_DEAD_CIRCUMFLEX ) { keyCodeString += " dead key "; } modString = "modifiers = " + modifiers; tmpString = KeyEvent.getKeyModifiersText(modifiers); if (tmpString.length() > 0) { modString += " (" + tmpString + ")"; } else { modString += " (no modifiers)"; } isString = "isKeys = isActionKey (" + e.isActionKey() + ")" + " isAltDown (" + e.isAltDown() + ")" + " isAltGraphDown (" + e.isAltGraphDown() + ")" + " isAltGraphDownLinux (" + isAltGr + ")" + " isControlDown (" + e.isControlDown() + ")" + " isMetaDown (" + e.isMetaDown() + ")" + " isShiftDown (" + e.isShiftDown() + ")"; String newline = "\n"; System.out.println(s + newline + " " + charString + newline + " " + keyCodeString + newline + " " + modString + newline + " " + isString + newline); }
Example 20
Source File: WebHotkeyLabel.java From weblaf with GNU General Public License v3.0 | 2 votes |
/** * Constructs hotkey label for the specified key code and modifiers. * * @param keyCode single key code * @param modifiers hotkey modifiers */ public WebHotkeyLabel ( final int keyCode, final int modifiers ) { super ( StyleId.hotkeylabel, KeyEvent.getKeyModifiersText ( modifiers ) + "+" + KeyEvent.getKeyText ( keyCode ) ); }