Jacky Luk wrote:
When posting code on a forum, it's a good idea to remove inane IDE-generated comments which only add clutter.
It is
never necessary to import classes from the java.lang package as the compiler automatically inserts an import-on-demand for java.lang.*
Rather than write your own empty implementations of all 3 KeyListener methods, you can extend KeyAdapter -- see the API.
If this is a Swing application, Kay Bindings are the way to go. Campbell has already posted a link to that particular section of the tutorials.