This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Adding a global keylistener

 
Eric Hoskland
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Eric
does JDC Techtip link mention what u r tryin to do..
regards
maulin
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic