I have an applet running in a browser tab. When I switch to a different tab in the same browser, or ALT-TAB to another application entirely, the applet loses focus. When I return to the browser tab, the applet doesn’t gain focus again. Is there a nice way to make this happen?
I assume it’s a JavaScript change that’s needed, not in the applet itself? Some onFocus handler perhaps? If it’s relevant, our applet is created using an HTML <applet> tag.
I believe java has the
requestFocus()method. It’s in the Component class, so your JPanel or whatever you are using may be able to use this.For the javascript part, this is what a quick googling reveals: http://www.raditha.com/java/javascript.php. I hope it helps you!