[java] Giving applets Focus first

Started by
3 comments, last by nullsmind 17 years, 12 months ago
Just a random question but just working on a simple pong game and when I load the applet within a html page, I firstly have to click on the applet to do anything on it. I know this isn't a major problem but just wondering if there is a way so when the page loads the applet is straight away under the player control? Unsure if this would be better placed within the html forum but hopefully it should be ok here. Thanks in advance. Nate
Advertisement
I think there is some java script you can call to set the input focus on a page so that could be the place to start

:-)
ujhkfkfk
lol durr silly me, thanks for the reply and silly me for not thinking about that :P

Cheers
irrc you can use the focus function of the DHTML applet tag in order to give focus to the applet though I am not sure if this will cause java to set the focus.

Example:
<applet      id="myapplet_id"     code="myapplet"     archive="mypackage.jar"     width=600     height=400     >Get java stupid!</applet>


And the &#106avascript for the page
onload = document.all("myapplet_id").focus();


I think that should help! Let me know if that works!
http://java.sun.com/developer/technicalArticles/J2SE/Desktop/ieappletguide/

This topic is closed to new replies.

Advertisement