List of usage examples for javax.swing JTextField getInputMap
public final InputMap getInputMap(int condition)
InputMap
that is used during condition
. 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); }