Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

applet focus

 
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?
 
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.
 
Climb the rope! CLIMB THE ROPE! You too tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic