List of usage examples for javax.swing.text Keymap getBoundActions
public Action[] getBoundActions();
From source file:Main.java
public static void main(String[] argv) throws Exception { JTextComponent component = new JTextField(); if (component instanceof JTextComponent) { JTextComponent textComp = (JTextComponent) component; Keymap keymap = textComp.getKeymap(); while (keymap != null) { Action[] actions = keymap.getBoundActions(); for (int i = 0; i < actions.length; i++) { Action action = actions[i]; }/*from w w w . ja v a 2 s.c o m*/ Action defaultAction = keymap.getDefaultAction(); keymap = keymap.getResolveParent(); } } }
From source file:net.sf.jabref.gui.keyboard.EmacsKeyBindings.java
private static void createBackup() { Keymap oldBackup = JTextComponent.getKeymap(EmacsKeyBindings.JTCS[0].getClass().getName()); if (oldBackup != null) { // if there is already a backup, do not create a new backup return;// w ww .ja v a 2s .co m } for (JTextComponent jtc : EmacsKeyBindings.JTCS) { Keymap orig = jtc.getKeymap(); Keymap backup = JTextComponent.addKeymap(jtc.getClass().getName(), null); Action[] bound = orig.getBoundActions(); for (Action aBound : bound) { KeyStroke[] strokes = orig.getKeyStrokesForAction(aBound); for (KeyStroke stroke : strokes) { backup.addActionForKeyStroke(stroke, aBound); } } backup.setDefaultAction(orig.getDefaultAction()); } }
From source file:net.sf.jabref.gui.keyboard.EmacsKeyBindings.java
/** * Restores the original keybindings for the concrete subclasses of * {@link JTextComponent}./*from w w w . j a va 2s. co m*/ * */ public static void unload() { for (int i = 0; i < EmacsKeyBindings.JTCS.length; i++) { Keymap backup = JTextComponent.getKeymap(EmacsKeyBindings.JTCS[i].getClass().getName()); if (backup != null) { Keymap current = EmacsKeyBindings.JTCS[i].getKeymap(); current.removeBindings(); Action[] bound = backup.getBoundActions(); for (Action aBound : bound) { KeyStroke[] strokes = backup.getKeyStrokesForAction(bound[i]); for (KeyStroke stroke : strokes) { current.addActionForKeyStroke(stroke, aBound); } } current.setDefaultAction(backup.getDefaultAction()); } } }