Skip to main content
gamedev.net
🔒 Locked

[java] Giving applets Focus first

Started by drackill 3 replies 1.1k views
Original Post
drackill
drackill
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
Chaoslab
Chaoslab
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
drackill
drackill
lol durr silly me, thanks for the reply and silly me for not thinking about that :P

Cheers
5MinuteGaming
5MinuteGaming
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 javascript for the page
onload = document.all("myapplet_id").focus();


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

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.