Example usage for javax.swing.text Keymap getResolveParent

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

Introduction

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

Prototype

public Keymap getResolveParent();

Source Link

Document

Fetches the parent keymap used to resolve key-bindings.

Usage

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 ww  .ja v a  2s . c  o m
            Action defaultAction = keymap.getDefaultAction();
            keymap = keymap.getResolveParent();
        }
    }
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JTextArea component = new JTextArea();
    Keymap map = component.getKeymap();

    while (map != null) {
        KeyStroke[] keys = map.getBoundKeyStrokes();

        for (int i = 0; i < keys.length; i++) {
            System.out.println(keys[i].getKeyChar());
            Action action = (Action) map.getAction(keys[i]);
            System.out.println(action);
        }//w  ww  .j ava2 s.  c  om
        Action defAction = map.getDefaultAction();
        System.out.println(defAction);
        map = map.getResolveParent();
    }
}

From source file:Main.java

public static Action findDefaultAction(JTextComponent c) {
    Keymap kmap = c.getKeymap();
    if (kmap.getDefaultAction() != null) {
        return kmap.getDefaultAction();
    }// ww  w. j a v  a2  s .  c  o  m

    kmap = kmap.getResolveParent();
    while (kmap != null) {
        if (kmap.getDefaultAction() != null) {
            return kmap.getDefaultAction();
        }
        kmap = kmap.getResolveParent();
    }
    return null;
}