Java Code Examples for javax.swing.text.JTextComponent#KeyBinding
The following examples show how to use
javax.swing.text.JTextComponent#KeyBinding .
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: bug6474153.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
private static void checkArray(JTextComponent.KeyBinding[] keyActionArray) { if (keyActionArray.length != 1) { throw new RuntimeException("Wrong array lenght!"); } if (!DefaultEditorKit.upAction.equals(keyActionArray[0].actionName)) { throw new RuntimeException("Wrong action name!"); } if (!KeyStroke.getKeyStroke("UP").equals(keyActionArray[0].key)) { throw new RuntimeException("Wrong keystroke!"); } }
Example 2
Source File: SyntaxEditorKit.java From nextreports-designer with Apache License 2.0 | 5 votes |
protected JTextComponent.KeyBinding[] getKeyBindings() { List<JTextComponent.KeyBinding> keyBindings = new ArrayList<JTextComponent.KeyBinding>(); keyBindings.addAll(Arrays.asList(getDefaultKeyBindings())); keyBindings.addAll(Arrays.asList(getCustomKeyBindings())); return keyBindings.toArray(new JTextComponent.KeyBinding[keyBindings.size()]); }
Example 3
Source File: bug6474153.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
private static void checkArray(JTextComponent.KeyBinding[] keyActionArray) { if (keyActionArray.length != 1) { throw new RuntimeException("Wrong array lenght!"); } if (!DefaultEditorKit.upAction.equals(keyActionArray[0].actionName)) { throw new RuntimeException("Wrong action name!"); } if (!KeyStroke.getKeyStroke("UP").equals(keyActionArray[0].key)) { throw new RuntimeException("Wrong keystroke!"); } }
Example 4
Source File: bug6474153.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private static void checkArray(JTextComponent.KeyBinding[] keyActionArray) { if (keyActionArray.length != 1) { throw new RuntimeException("Wrong array lenght!"); } if (!DefaultEditorKit.upAction.equals(keyActionArray[0].actionName)) { throw new RuntimeException("Wrong action name!"); } if (!KeyStroke.getKeyStroke("UP").equals(keyActionArray[0].key)) { throw new RuntimeException("Wrong keystroke!"); } }
Example 5
Source File: bug6474153.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
private static void checkArray(JTextComponent.KeyBinding[] keyActionArray) { if (keyActionArray.length != 1) { throw new RuntimeException("Wrong array lenght!"); } if (!DefaultEditorKit.upAction.equals(keyActionArray[0].actionName)) { throw new RuntimeException("Wrong action name!"); } if (!KeyStroke.getKeyStroke("UP").equals(keyActionArray[0].key)) { throw new RuntimeException("Wrong keystroke!"); } }
Example 6
Source File: bug6474153.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private static void checkArray(JTextComponent.KeyBinding[] keyActionArray) { if (keyActionArray.length != 1) { throw new RuntimeException("Wrong array lenght!"); } if (!DefaultEditorKit.upAction.equals(keyActionArray[0].actionName)) { throw new RuntimeException("Wrong action name!"); } if (!KeyStroke.getKeyStroke("UP").equals(keyActionArray[0].key)) { throw new RuntimeException("Wrong keystroke!"); } }
Example 7
Source File: bug6474153.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
private static void checkArray(JTextComponent.KeyBinding[] keyActionArray) { if (keyActionArray.length != 1) { throw new RuntimeException("Wrong array lenght!"); } if (!DefaultEditorKit.upAction.equals(keyActionArray[0].actionName)) { throw new RuntimeException("Wrong action name!"); } if (!KeyStroke.getKeyStroke("UP").equals(keyActionArray[0].key)) { throw new RuntimeException("Wrong keystroke!"); } }
Example 8
Source File: bug6474153.java From hottub with GNU General Public License v2.0 | 5 votes |
private static void checkArray(JTextComponent.KeyBinding[] keyActionArray) { if (keyActionArray.length != 1) { throw new RuntimeException("Wrong array lenght!"); } if (!DefaultEditorKit.upAction.equals(keyActionArray[0].actionName)) { throw new RuntimeException("Wrong action name!"); } if (!KeyStroke.getKeyStroke("UP").equals(keyActionArray[0].key)) { throw new RuntimeException("Wrong keystroke!"); } }
Example 9
Source File: bug6474153.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private static void checkArray(JTextComponent.KeyBinding[] keyActionArray) { if (keyActionArray.length != 1) { throw new RuntimeException("Wrong array lenght!"); } if (!DefaultEditorKit.upAction.equals(keyActionArray[0].actionName)) { throw new RuntimeException("Wrong action name!"); } if (!KeyStroke.getKeyStroke("UP").equals(keyActionArray[0].key)) { throw new RuntimeException("Wrong keystroke!"); } }
Example 10
Source File: bug6474153.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static void checkArray(JTextComponent.KeyBinding[] keyActionArray) { if (keyActionArray.length != 1) { throw new RuntimeException("Wrong array lenght!"); } if (!DefaultEditorKit.upAction.equals(keyActionArray[0].actionName)) { throw new RuntimeException("Wrong action name!"); } if (!KeyStroke.getKeyStroke("UP").equals(keyActionArray[0].key)) { throw new RuntimeException("Wrong keystroke!"); } }
Example 11
Source File: bug6474153.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private static void checkArray(JTextComponent.KeyBinding[] keyActionArray) { if (keyActionArray.length != 1) { throw new RuntimeException("Wrong array lenght!"); } if (!DefaultEditorKit.upAction.equals(keyActionArray[0].actionName)) { throw new RuntimeException("Wrong action name!"); } if (!KeyStroke.getKeyStroke("UP").equals(keyActionArray[0].key)) { throw new RuntimeException("Wrong keystroke!"); } }
Example 12
Source File: MultiKeymap.java From netbeans with Apache License 2.0 | 5 votes |
/** Loads key to action mappings into this keymap * @param bindings array of bindings * @param actions map of [action_name, action] pairs */ public void load(JTextComponent.KeyBinding[] bindings, Map actions) { // now create bindings in keymap(s) for (int i = 0; i < bindings.length; i++) { Action a = (Action)actions.get(bindings[i].actionName); if (a != null) { boolean added = false; if (bindings[i] instanceof MultiKeyBinding) { MultiKeyBinding mb = (MultiKeyBinding)bindings[i]; if (mb.keys != null) { Keymap cur = delegate; for (int j = 0; j < mb.keys.length; j++) { if (j == mb.keys.length - 1) { // last keystroke in sequence cur.addActionForKeyStroke(mb.keys[j], a); } else { // not the last keystroke Action sca = cur.getAction(mb.keys[j]); if (!(sca instanceof KeymapSetContextAction)) { sca = new KeymapSetContextAction(JTextComponent.addKeymap(null, null)); cur.addActionForKeyStroke(mb.keys[j], sca); } cur = ((KeymapSetContextAction)sca).contextKeymap; } } added = true; } } if (!added) { if (bindings[i].key != null) { delegate.addActionForKeyStroke(bindings[i].key, a); } else { // key is null -> set default action setDefaultAction(a); } } } } }
Example 13
Source File: SyntaxEditorKit.java From nextreports-designer with Apache License 2.0 | 5 votes |
private JTextComponent.KeyBinding[] getDefaultKeyBindings() { return new JTextComponent.KeyBinding[] { new JTextComponent.KeyBinding(KeyStroke.getKeyStroke("control Z"), undoAction), new JTextComponent.KeyBinding(KeyStroke.getKeyStroke("control Y"), redoAction), new JTextComponent.KeyBinding(KeyStroke.getKeyStroke("TAB"), indentAction), new JTextComponent.KeyBinding(KeyStroke.getKeyStroke("shift TAB"), unindentAction) }; }
Example 14
Source File: bug6474153.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private static void checkArray(JTextComponent.KeyBinding[] keyActionArray) { if (keyActionArray.length != 1) { throw new RuntimeException("Wrong array lenght!"); } if (!DefaultEditorKit.upAction.equals(keyActionArray[0].actionName)) { throw new RuntimeException("Wrong action name!"); } if (!KeyStroke.getKeyStroke("UP").equals(keyActionArray[0].key)) { throw new RuntimeException("Wrong keystroke!"); } }
Example 15
Source File: bug6474153.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private static void checkArray(JTextComponent.KeyBinding[] keyActionArray) { if (keyActionArray.length != 1) { throw new RuntimeException("Wrong array lenght!"); } if (!DefaultEditorKit.upAction.equals(keyActionArray[0].actionName)) { throw new RuntimeException("Wrong action name!"); } if (!KeyStroke.getKeyStroke("UP").equals(keyActionArray[0].key)) { throw new RuntimeException("Wrong keystroke!"); } }
Example 16
Source File: bug6474153.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private static void checkArray(JTextComponent.KeyBinding[] keyActionArray) { if (keyActionArray.length != 1) { throw new RuntimeException("Wrong array lenght!"); } if (!DefaultEditorKit.upAction.equals(keyActionArray[0].actionName)) { throw new RuntimeException("Wrong action name!"); } if (!KeyStroke.getKeyStroke("UP").equals(keyActionArray[0].key)) { throw new RuntimeException("Wrong keystroke!"); } }
Example 17
Source File: BaseEditorKit.java From nextreports-designer with Apache License 2.0 | 4 votes |
@Override protected KeyBinding[] getCustomKeyBindings() { return new JTextComponent.KeyBinding[] { new JTextComponent.KeyBinding(KeyStroke.getKeyStroke("control F"), findReplaceAction), }; }
Example 18
Source File: MultiKeyBinding.java From netbeans with Apache License 2.0 | 4 votes |
/** Constructor for existing KeyBinding */ public MultiKeyBinding(JTextComponent.KeyBinding kb) { this(kb.key, kb.actionName); }
Example 19
Source File: GUIMain.java From PacketProxy with Apache License 2.0 | 4 votes |
/** * JTextPane上でCommand+Cとかでコピペをできるようにする */ private void addShortcutForMac() { if (!PacketProxyUtility.getInstance().isMac()) { return; } JPanel p = (JPanel) getContentPane(); InputMap im = p.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); ActionMap am = p.getActionMap(); int hotkey = (KeyEvent.CTRL_MASK | KeyEvent.META_MASK); registerTabShortcut(KeyEvent.VK_H, hotkey, im, am, Panes.HISTORY.ordinal()); registerTabShortcut(KeyEvent.VK_I, hotkey, im, am, Panes.INTERCEPT.ordinal()); registerTabShortcut(KeyEvent.VK_R, hotkey, im, am, Panes.REPEATER.ordinal()); registerTabShortcut(KeyEvent.VK_B, hotkey, im, am, Panes.BULKSENDER.ordinal()); registerTabShortcut(KeyEvent.VK_O, hotkey, im, am, Panes.OPTIONS.ordinal()); registerTabShortcut(KeyEvent.VK_L, hotkey, im, am, Panes.LOG.ordinal()); JTextComponent.KeyBinding[] bindings1 = { new JTextComponent.KeyBinding( KeyStroke.getKeyStroke(KeyEvent.VK_C, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()), DefaultEditorKit.copyAction), new JTextComponent.KeyBinding( KeyStroke.getKeyStroke(KeyEvent.VK_V, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()), DefaultEditorKit.pasteAction), new JTextComponent.KeyBinding( KeyStroke.getKeyStroke(KeyEvent.VK_X, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()), DefaultEditorKit.cutAction), new JTextComponent.KeyBinding( KeyStroke.getKeyStroke(KeyEvent.VK_A, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()), DefaultEditorKit.selectAllAction), }; JTextPane component_tp = new JTextPane(); Keymap keymap_tp = component_tp.getKeymap(); JTextComponent.loadKeymap(keymap_tp, bindings1, component_tp.getActions()); JTextField component_tf = new JTextField(); Keymap keymap_tf = component_tf.getKeymap(); JTextComponent.loadKeymap(keymap_tf, bindings1, component_tf.getActions()); JTextArea component_ta = new JTextArea(); Keymap keymap_ta = component_ta.getKeymap(); JTextComponent.loadKeymap(keymap_ta, bindings1, component_ta.getActions()); }
Example 20
Source File: SyntaxEditorKit.java From nextreports-designer with Apache License 2.0 | 4 votes |
protected JTextComponent.KeyBinding[] getCustomKeyBindings() { return new JTextComponent.KeyBinding[0]; }