Java Code Examples for javax.swing.KeyStroke#toString()
The following examples show how to use
javax.swing.KeyStroke#toString() .
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: TransportWizard.java From mars-sim with GNU General Public License v3.0 | 6 votes |
private void setKeyBindings() { int condition = javax.swing.JComponent.WHEN_IN_FOCUSED_WINDOW; final javax.swing.InputMap inputMap = mapPanel.getInputMap(condition); final javax.swing.ActionMap actionMap = mapPanel.getActionMap(); boolean[] keyPressed = { true, false }; //boolean[] keys = new boolean[KeyEvent.KEY_TYPED]; //keys[evt.getKeyCode()] = true; for (Integer keyCode : keyboardMap.keySet()) { KeyboardDirection dir = keyboardMap.get(keyCode); for (boolean onKeyPress : keyPressed) { boolean onKeyRelease = !onKeyPress; KeyStroke keyStroke = KeyStroke.getKeyStroke(keyCode, 0, onKeyRelease); Object key = keyStroke.toString(); inputMap.put(keyStroke, key); actionMap.put(key, new KeyBindingsAction(dir, onKeyPress)); } } }
Example 2
Source File: OutlineView.java From netbeans with Apache License 2.0 | 5 votes |
private void putActionDelegate(InputMap map, KeyStroke ks) { String binding = COPY_ACTION_DELEGATE+ks.toString(); Action action = getCopyActionDelegate(map, ks); if (action != null) { getActionMap().put(binding, action); map.put(ks, binding); } }
Example 3
Source File: CodeTemplateManagerOperation.java From netbeans with Apache License 2.0 | 5 votes |
private static String getExpandKeyStrokeText(KeyStroke keyStroke) { String expandKeyStrokeText; if (keyStroke.equals(KeyStroke.getKeyStroke(' '))) { //NOI18N expandKeyStrokeText = "SPACE"; // NOI18N } else if (keyStroke.equals(KeyStroke.getKeyStroke(new Character(' '), InputEvent.SHIFT_MASK))) { //NOI18N expandKeyStrokeText = "Shift-SPACE"; // NOI18N } else if (keyStroke.equals(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0))) { expandKeyStrokeText = "TAB"; // NOI18N } else if (keyStroke.equals(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0))) { expandKeyStrokeText = "ENTER"; // NOI18N } else { expandKeyStrokeText = keyStroke.toString(); } return expandKeyStrokeText; }
Example 4
Source File: JCheckList.java From pgptool with GNU General Public License v3.0 | 5 votes |
private void addSpaceActionhandler(JComponent host) { InputMap inputMap = host.getInputMap(); ActionMap actionMap = host.getActionMap(); KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0); String key = keyStroke.toString(); inputMap.put(keyStroke, key); actionMap.put(key, invertCheckAction); }
Example 5
Source File: MenuKeyPreferences.java From gcs with Mozilla Public License 2.0 | 5 votes |
private void setAccelerator(JButton button, KeyStroke ks) { Command cmd = mMap.get(button); cmd.setAccelerator(ks); button.setText(getAcceleratorText(cmd)); button.invalidate(); Preferences prefs = Preferences.getInstance(); String key = cmd.getCommand(); String override = null; if (!cmd.hasOriginalAccelerator()) { override = ks != null ? ks.toString() : NONE; } prefs.setKeyBindingOverride(key, override); }
Example 6
Source File: FreeColAction.java From freecol with GNU General Public License v2.0 | 2 votes |
/** * Creates a {@code String} that keeps the attributes given * {@code KeyStroke}. This {@code String} can be used to * store the key stroke in an XML-file. * * @param keyStroke The {@code KeyStroke}. * @return A {@code String} that produces a key stroke equal to the * given {@code KeyStroke} if passed as a parameter to * {@code getAWTKeyStroke(String)}. */ private static String getKeyStrokeText(KeyStroke keyStroke) { return (keyStroke == null) ? "" : keyStroke.toString(); }