Example usage for javax.swing KeyStroke getKeyStroke

List of usage examples for javax.swing KeyStroke getKeyStroke

Introduction

In this page you can find the example usage for javax.swing KeyStroke getKeyStroke.

Prototype

public static KeyStroke getKeyStroke(String s) 

Source Link

Document

Parses a string and returns a KeyStroke.

Usage

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);

}

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);

    inputMap.clear();/*  w  w w.  j av a2  s .c  o m*/

}

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.getParent());

}

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.size());

}

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 {
    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.get(KeyStroke.getKeyStroke("F2")));

}

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.keys().length);

}

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);

    inputMap.remove(KeyStroke.getKeyStroke("F2"));

}

From source file:Main.java

public static void main(String[] argv) {
    JTextField component = new JTextField(10);

    component.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("typed X"), "none");

    JFrame f = new JFrame();
    f.add(component);/* w w  w .ja  v a2 s.  c o  m*/
    f.setSize(300, 300);
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] argv) {
    JTextField component = new JTextField(10);

    component.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("typed -"), "actionName");

    JFrame f = new JFrame();
    f.add(component);/*from ww  w  .  j  a  v a  2 s  .co m*/

    f.setSize(300, 300);

    f.setVisible(true);

}