Example usage for javax.swing.text Keymap removeBindings

List of usage examples for javax.swing.text Keymap removeBindings

Introduction

In this page you can find the example usage for javax.swing.text Keymap removeBindings.

Prototype

public void removeBindings();

Source Link

Document

Removes all bindings from the keymap.

Usage

From source file:net.sf.jabref.gui.keyboard.EmacsKeyBindings.java

/**
 * Restores the original keybindings for the concrete subclasses of
 * {@link JTextComponent}./*from   ww w .  j av  a 2  s .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());
        }
    }
}