I've registered key bindings to button and I'd like to react to all number key-strokes. I could register different event to every single key(0-9), but that's kind of stupid. So is it possible to handle it all in one event?
Here is my code that reacts only to key 0 on numpad:
private void setKeyBindings() {
AbstractAction aa = new AbstractAction() {
@Override
public void actionPerformed(ActionEvent ae) {
System.out.println("Here");
}
};
this.editButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_NUMPAD0, 0), "0");
this.editButton.getActionMap().put("0", aa);
}
Thanks