List of utility methods to do Swing Key Event
void | retargetKeyEvent(KeyEvent e, Component target) retarget Key Event if ((target == null) || (target == e.getSource())) { return; target.dispatchEvent(e); |
void | setKeystroke(JMenuItem m, int key) set Keystroke if (key > 0) { if (key != KeyEvent.VK_DELETE) m.setAccelerator(KeyStroke.getKeyStroke(key, Event.CTRL_MASK, false)); else m.setAccelerator(KeyStroke.getKeyStroke(key, 0, false)); |
void | simulateKeyPressed(Component component, int key) Simulate a key press/release event on the component. component.dispatchEvent(new KeyEvent(component, KeyEvent.KEY_PRESSED, 0, 1, key, KeyEvent.CHAR_UNDEFINED)); component.dispatchEvent(new KeyEvent(component, KeyEvent.KEY_RELEASED, 0, 2, key, KeyEvent.CHAR_UNDEFINED)); |