List of usage examples for javax.swing KeyStroke getKeyStroke
public static KeyStroke getKeyStroke(String s)
KeyStroke
. 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);/* ww w. j a v a 2 s . c om*/ 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 www. jav a 2s. com 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 w w .j ava2 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 ava2s . c o m*/ f.setSize(300, 300); f.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JButton component = new JButton("Button"); component.getInputMap().put(KeyStroke.getKeyStroke("F2"), "actionName"); component.getInputMap().put(KeyStroke.getKeyStroke("control A"), "actionName"); component.getInputMap().put(KeyStroke.getKeyStroke("shift F2"), "actionName"); component.getInputMap().put(KeyStroke.getKeyStroke('('), "actionName"); component.getInputMap().put(KeyStroke.getKeyStroke("button3 F"), "actionName"); component.getInputMap().put(KeyStroke.getKeyStroke("typed x"), "actionName"); component.getInputMap().put(KeyStroke.getKeyStroke("released DELETE"), "actionName"); component.getInputMap().put(KeyStroke.getKeyStroke("shift UP"), "actionName"); component.getActionMap().put("actionName", new AbstractAction("actionName") { public void actionPerformed(ActionEvent evt) { System.out.println(evt); }/*from w w w . ja v a 2 s . c o m*/ }); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JButton component = new JButton("a"); Set set = new HashSet(component.getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS)); set.add(KeyStroke.getKeyStroke("F2")); component.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, set); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JButton component = new JButton(); MyAction action = new MyAction(); component.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("F2"), action.getValue(Action.NAME)); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JButton component = new JButton(); MyAction action = new MyAction(); component.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke("F2"), action.getValue(Action.NAME)); }
From source file:Main.java
public static void main(String[] argv) throws Exception { Set<AWTKeyStroke> set = new HashSet<AWTKeyStroke>(KeyboardFocusManager.getCurrentKeyboardFocusManager() .getDefaultFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS)); set.add(KeyStroke.getKeyStroke("F2")); KeyboardFocusManager.getCurrentKeyboardFocusManager() .setDefaultFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, set); }
From source file:Main.java
public static void main(String[] argv) throws Exception { Set<AWTKeyStroke> set = new HashSet<AWTKeyStroke>(KeyboardFocusManager.getCurrentKeyboardFocusManager() .getDefaultFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS)); set.add(KeyStroke.getKeyStroke("F3")); KeyboardFocusManager.getCurrentKeyboardFocusManager() .setDefaultFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, set); }