Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > KeyListener

Reply
Thread Tools

KeyListener

 
 
Luc The Perverse
Guest
Posts: n/a
 
      11-12-2005
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.

--
LTP




 
Reply With Quote
 
 
 
 
Michael Dunn
Guest
Posts: n/a
 
      11-12-2005

"Luc The Perverse" <(E-Mail Removed)> wrote in message
news:43758449$0$8288$(E-Mail Removed). ..
> 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);


 
Reply With Quote
 
 
 
 
Luc The Perverse
Guest
Posts: n/a
 
      11-12-2005
"Michael Dunn" <(E-Mail Removed)> wrote in message
news:43758e7a$(E-Mail Removed)...
>
> "Luc The Perverse" <(E-Mail Removed)> wrote in message
> news:43758449$0$8288$(E-Mail Removed). ..
>> 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);


SWEET!

I had no idea it would be that simple. Thank you!

--
LTP




 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
keylistener problem with applet biner.sebastien@ouranos.ca Java 0 01-03-2006 06:35 PM
KeyListener losing its way JavaEnquirer Java 0 12-20-2005 05:00 PM
JWindow KeyListener Max Java 4 10-29-2005 04:24 AM
KeyListener vs. Runnable ??? JariTapio Java 2 03-25-2005 02:06 PM
Wierd problem with KeyListener and contentPane in applet. apchar Java 3 02-03-2004 04:10 AM



Advertisments