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:InsertAction.java

public static void main(String[] argv) {
    JTextField component = new JTextField(10);
    InsertAction insertSpaceAction = new InsertAction();
    component.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(new Character(' '), 0), "none");

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

    component.getActionMap().put(insertSpaceAction.getValue(Action.NAME), insertSpaceAction);

    JFrame f = new JFrame();
    f.add(component);//from  w  ww.  ja  va 2s  . c  o m
    f.setSize(300, 300);
    f.setVisible(true);
}

From source file:InsertAction.java

public static void main(String[] argv) {
    JTextField component = new JTextField(10);
    InsertAction insertSpaceAction = new InsertAction();
    component.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(new Character(' '), 0), "none");

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

    component.getActionMap().put(insertSpaceAction.getValue(Action.NAME), insertSpaceAction);

    JFrame f = new JFrame();
    f.add(component);/* w  w  w.  j a  va 2s. c  om*/

    f.setSize(300, 300);

    f.setVisible(true);

}