Using the keyboard event, when the click event and other incidents, some attention points:
When using the keyboard events:
Such as: setting up keyboard events KeyListener in JPanel panel, then you need to add this.setFocusable (true) ;, so that the focus can be used on the panel.
Other events, no need to write this.setFocusable (true);
More events exist when:
As the focus of the question, it will lead to some events will fail. Such as: use of KeyListener keyboard events, ActionListener click event, which will lead to the failure of an event, you need to add this.requestFocus on creating events panel () ;, regain focus.