Firefox and applet focus

I have had a long running issue with Firefox and applets where an applet loses focus (usually switching tabs) and will not regain it when switching back or with a mouse click. I generally give up trying to sort this out and just end up putting this in the rendering loop:


if (!hasFocus()) {
    requestFocus();
}

Obviously this is sub-optimal and I would like to get this sorted once and for all. Does anybody have a reliable way of managing applet focus. Also can someone tell me why a focusable object refuses to gain focus on a mouse click?

The applet I am working on below works about half the time initially and pretty much always stops responding to key inputs when switching tabs.

http://www.angryoctopus.co.nz/webguitar/screen_1.png

Let me know if it works for you and which browser you are using (left/right keys for strum).

No one else has this problem? Maybe it is a Linux specific thing.

Changed the app to checking the focus status on MouseMoved events and calling requestFocus() if I don’t have it. Interestingly using the preferred requestFocusInWindow() doesn’t work.

Usually the applet shoul receive focus when the user clicks on it (again). It should not force focus otherwise, the user might want to have the focus elsewhere, like in the address bar. Dont steal that.

When your applet doesnt get focus when the user clicks on it, its hard to tell with the few information given. I would at first assume, that there is something top level that is not enabled or not focusable or anything that blocks the java focus handling.

-JAW