Example usage for javax.swing JTextField getInputMap

List of usage examples for javax.swing JTextField getInputMap

Introduction

In this page you can find the example usage for javax.swing JTextField getInputMap.

Prototype

public final InputMap getInputMap(int condition) 

Source Link

Document

Returns the InputMap that is used during condition.

Usage

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);//ww  w. jav a2s. 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(new Character(' '), 0), "none");

    JFrame f = new JFrame();
    f.add(component);/*from  ww  w .  j av  a 2 s.co  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);/* www . j av  a2  s.co  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 a"), "actionName");

    JFrame f = new JFrame();
    f.add(component);//from w  w  w.  j  av  a 2  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 X"), "none");

    JFrame f = new JFrame();
    f.add(component);//from   ww  w  .  j ava 2  s  .co 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);// w  ww  .  ja  va  2 s.  co 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(new Character(' '), 0),
            "actionName");

    JFrame f = new JFrame();
    f.add(component);//from w  w  w . j  ava  2  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("shift pressed SPACE"),
            "actionName");

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

    f.setSize(300, 300);

    f.setVisible(true);

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    final Action action = new AbstractAction("Action Name") {
        public void actionPerformed(ActionEvent evt) {
            System.out.println("action");
        }//from w ww  .  jav  a 2  s  .  co  m
    };

    JFrame frame = new JFrame();
    JButton button = new JButton(action);

    JTextField textfield = new JTextField();
    textfield.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("F2"),
            action.getValue(Action.NAME));
    textfield.getActionMap().put(action.getValue(Action.NAME), action);
}

From source file:Main.java

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

    // Override letter a
    component.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("typed a"), "actionName");

    component.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(new Character(' '), 0),
            "actionName");

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

    component.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("shift pressed SPACE"),
            "actionName");

    component.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(new Character(' '), 0), "none");

    MyAction action = new MyAction();

    component.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("pressed SPACE"),
            action.getValue(Action.NAME));

    component.getActionMap().put(action.getValue(Action.NAME), action);
}