This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Applets and the fly likes KeyListener - Please Help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "KeyListener - Please Help" Watch "KeyListener - Please Help" New topic
Author

KeyListener - Please Help

D Miller
Greenhorn

Joined: Aug 05, 2003
Posts: 4
I have compiled the following code in JBuilder, and it works exactly like I want it to. But, in IE and appletviewer it doesn't work at all. It will not accept any key strokes. The timer should start when the space bar is pressed when working properly. Thanks.
Grub de Bliek
Greenhorn

Joined: Sep 09, 2003
Posts: 19
The problem is the initial focus. I once had that problem too, and solved it with a workaround. Didn't solve it that is...
Anyway, it's something with the AWT-Event thread. When initialising and starting the applet you're not in the awt-event thread.
I changed your code a bit as example, and added a second Timer that gets the focus after 2 seconds. Without timer it works too, but then the user have to click once on the applet.
If you want to solve this problem correctly you've to find an expert with the AWT-Event thread.



When the compiler isn't happy, nobody is happy...
D Miller
Greenhorn

Joined: Aug 05, 2003
Posts: 4
Thanks for your help. I had a feeling there was not real easy solution. I appreciate your response.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: KeyListener - Please Help
 
Similar Threads
addKeyListener() help needed plz
Counting Lines
Key Events / Which keys are which?
keyboard events
how to implement mvc or observer pattern on this java code ?