Java KeyBindings: How does it work?
问题 I keep seeing that I should use Key Bindings instead of KeyListeners. So I found this page: Key Bindings. I read through it and tried to implement it. Action numPressed = new AbstractAction() { public void actionPerformed(ActionEvent e) { System.out.println("hi"); } }; this.getInputMap().put(KeyStroke.getKeyStroke("1"), "released"); this.getActionMap().put("released", numPressed); I decided to just see what would happen. The class this is in extends a JPanel. Earlier, I used this.setFocusable