| Author |
How do I get my applet to get focus?
|
Anton Westbergh
Greenhorn
Joined: Mar 24, 2004
Posts: 5
|
|
I am writing a little Tetris-clone, which you can test here: http://members.chello.se/foobar/anton/projektarbetet/source/Tetris%200.7/ I have a problem. The applet doesn't get focus when entering the page, and you have to click it with the mouse before you can do anything. (Before it registers key-events and so on) Can I help this with some simple JavaScript? Any help would be VERY welcome, since I don't have the time to learn all JavaScript tonight, and would very much like to get this fix done ;D Best regards! /Anton
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24057
|
|
|
Moving to "Applets" forum.
|
[Jess in Action][AskingGoodQuestions]
|
 |
Dirk Schreckmann
Sheriff
Joined: Dec 10, 2001
Posts: 7023
|
|
Welcome to JavaRanch, Anton! Allow me to continue Ernest's thought, and let's continue this conversation over in the Applets forum... [ March 26, 2004: Message edited by: Dirk Schreckmann ]
|
[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
|
 |
wayne hitchcock
Greenhorn
Joined: Dec 22, 2003
Posts: 8
|
|
I've written a number of applets and found this to be a problem on some browsers, so what I suggest may or may not work. In the applet class's init() method write: this.requestFocusInWindow(); If it works the applet will have focus. If your applet uses mnemonics be sure they are different from the mnemonics your browser uses because it is the browser's mnemonics that will be invoked.
|
 |
Anton Westbergh
Greenhorn
Joined: Mar 24, 2004
Posts: 5
|
|
Well, I tried this.requestFocusInWindow(); but it doesn't help.. You can see for yourselves at: www.elitris.com Enter the page, and see what I mean. You must click the applet, or it doesn't get focus. regards /Anton
|
 |
 |
|
|
subject: How do I get my applet to get focus?
|
|
|