KeyListener

L

Luc The Perverse

In an attempt to familiarize myself with Sprite animation I have made an
exceptionally simple example.

I have a class called AnimationFrame (class AnimationFrame extends
javax.swing.JPanel implements Runnable, KeyListener) but I can't seem to get
it to keylistener events unless I drop an object in there and give it focus.

Any way I can avoid this? I don't want to have to have a fake control on
the front of my game.
 
M

Michael Dunn

Luc The Perverse said:
In an attempt to familiarize myself with Sprite animation I have made an
exceptionally simple example.

I have a class called AnimationFrame (class AnimationFrame extends
javax.swing.JPanel implements Runnable, KeyListener) but I can't seem to
get it to keylistener events unless I drop an object in there and give it
focus.

Any way I can avoid this? I don't want to have to have a fake control on
the front of my game.


do you have in the AnimationFrame constructor

setFocusable(true);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,479
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top