I've searched this forum for similar topics and found a few but they didn't help me, so I'm starting a new thread.
I have a small collection of logic games implemented as Java applets. Some of them are controlled with keys and the problem is that the game field is not getting the focus upon loading of the applet in the browser. I tried to overcome the issue by adding a call to requestFocusInWindow() in the init() and start() methods or in different event handlers (for example, in the handler for the New item of the game menu). That helped but not completely: I got consistent behavior in some browser+OS configurations and had no success in others. For example, on the same Windows machine I need to click the game field twice if I load the game with Opera and can play right upon loading if the same game is loaded with Internet Explorer. Could someone suggest me the best technique to get focus to a Canvas placed within the Applet's content panel? Maybe, there are some peculiarities I need to know? Currently, to work around the issue I make the user to select the New item in the game menu in order to start the game - but I don't like this way because most users expect the game to be ready to play once it is loaded and they see the game field. Moreover, this only works for 7 shapes and Snake but still doesn't enable the keys for 15 puzzle if I use Opera under Windows. If it helps, here you can play the games I'm talking about my games site.
Thank you in advance for your advices.