Java KeyListener for JPane
Go to solution
Solved by AngusBrown,
You have already implemented the KeyListener Interface, so the last thing to do is to assign it to the JPanel.
What you need to do in the constructor:
addKeyListener(this);
Documentation: https://docs.oracle.com/javase/8/docs/api/java/awt/Component.html#addKeyListener-java.awt.event.KeyListener-

Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now