This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

applet focus

 
D Miller
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using a JApplet with a KeyListener associated with it. The applet is a simple test; to start the applet the user simply pushes the space bar. This works fine except that before pressing the space bar, you must first click on the applet to give it focus.
Is there any way to easily give the applet focus (to get the applet ready to accept keystrokes) without having to click on the applet?
 
Caven Wang
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Would u like to try using JavaScript . on body loaded, make the applet "object " is onfocus!
 
D Miller
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply. I tried to use javascript but still could not get it to work. I tried the following in the body's onload tag.

but the focus() method is really for a text box is suppose.
You said onfocus but I was unsure how to do that.
Any other suggestions would be great. Thanks.
 
Caven Wang
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try to insert applet as an object and set its ID. You may call the ID in your js.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic