A Java applet has the following in its start() method :
When launched, the applet grabs the focus only in certain OS/JRE/browser configurations. It's compiled using JDK 1.6.0_18, and on my PC running Java 1.7 it grabs focus in all browsers (Ie, chrome, Firefox) without problems; even if the applet is compiled using JDK 1.7.
On Mac OS X 10.6.8 which comes with Java 1.6.0_29 it doesn't grab focus in Safari, Chrome or Firefox, but the applet loads fine. When I upgrade the the Mac OSX JDK to the preview 1.7 - it doesnt' load the applet at all. If I compile the applet using JDK 1.7 and run using JRE 1.7 - it just crashes the browsers on the Mac.
Has anyone come across similar problems? thanks.Answer1:
The docs. for <a href="http://docs.oracle.com/javase/7/docs/api/java/awt/Component.html#requestFocus%28%29" rel="nofollow">
Because the focus behavior of this method is platform-dependent, developers are strongly encouraged to use <a href="http://docs.oracle.com/javase/7/docs/api/java/awt/Component.html#requestFocusInWindow%28%29" rel="nofollow">
requestFocusInWindow</a> when possible.
Is it <em>possible</em> to use the latter in this case?<blockquote>
Has anyone come across similar problems?</blockquote>
Focus problems go hand-in-hand with embedded applets. If you want more reliable focus behavior, launch the applet free-floating using <a href="https://stackoverflow.com/tags/java-web-start/info" rel="nofollow">Java Web Start</a>.