This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Applets and the fly likes Adding a global keylistener Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Applets
Reply Bookmark "Adding a global keylistener" Watch "Adding a global keylistener" New topic
Author

Adding a global keylistener

Eric Hoskland
Greenhorn

Joined: Oct 12, 2000
Posts: 29
I already posted this in the AWT/SWING forum and then figured it was better suited here in APPLETS. So I apologize in advance for the double posting.
NOT A SWING QUESTION:
How do I add a "global" Keylistener to my GUI.
My main GUI extends FRAME and then upon creation of my GUI I create a bunch of panels and a message area. How do I add a keylistener that will run whenever a key is hit.
I tried doing things like:
this.addKeyListener(this);
this.addKeyListener(new KeyboardListener);
super.addKeyListener(this);
They all compile fine but the listener never runs. The best I can do is add listeners to buttons or message areas that I know will be selected at certain points in time. But that seems ineffecient. I want a listener to be always active no matter what in my frame has focus.
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1865
hi Eric
does JDC Techtip link mention what u r tryin to do..
regards
maulin


1. Have fun @ http://faq.javaranch.com/java/JavaRaq
2. Looking for simple infix2postfix conversion and postfix evaluation package? Click here
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Adding a global keylistener
 
Similar Threads
Problems about KeyEvent and Policy file.
Adding KeyListener
want to do some action when input is typed in Swing JPanel components
KeyListerner in JPanel
Questin on listeners