Example usage for javax.swing InputMap allKeys

List of usage examples for javax.swing InputMap allKeys

Introduction

In this page you can find the example usage for javax.swing InputMap allKeys.

Prototype

public KeyStroke[] allKeys() 

Source Link

Document

Returns an array of the KeyStroke s defined in this InputMap and its parent.

Usage

From source file:Main.java

public static void main(String[] args) {
    JTree tree = new JTree();
    InputMap inputMap = tree.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    KeyStroke[] keyStrokes = inputMap.allKeys();
    for (KeyStroke keyStroke : keyStrokes) {
        Object actionCommand = inputMap.get(keyStroke);
        System.out.println("keyStroke = " + keyStroke);
        System.out.println("actionCommand = " + actionCommand);
    }/*from w  w  w  . java2s. c om*/
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    InputMap inputMap = new InputMap();

    inputMap.put(KeyStroke.getKeyStroke("F2"), "actionName");

    JButton component = new JButton("button");

    inputMap.setParent(component.getInputMap(JComponent.WHEN_FOCUSED));
    component.setInputMap(JComponent.WHEN_FOCUSED, inputMap);

    System.out.println(inputMap.allKeys().length);

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JButton component = new JButton("button");
    InputMap map = component.getInputMap(JComponent.WHEN_FOCUSED);
    list(map, map.keys());/* w w  w  .j  ava  2  s.  c o m*/
    list(map, map.allKeys());
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JButton component = new JButton("button");
    InputMap map = component.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    list(map, map.keys());//from  ww  w. j  a v  a  2  s .c o m
    list(map, map.allKeys());
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JButton component = new JButton();
    InputMap map = component.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    list(map, map.keys());/* ww w .jav a2 s .  c om*/
    list(map, map.allKeys());
}