java applet not grabbing focus in JRE 1.6.0_29 and up (OS X)


A Java applet has the following in its start() method :

this.setFocusable(true); this.requestFocus();

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.


The docs. for <a href="http://docs.oracle.com/javase/7/docs/api/java/awt/Component.html#requestFocus%28%29" rel="nofollow">Component.requestFocus()</a> state:


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?


Has anyone come across similar problems?


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>.


  • stdin/stdout communication between Java program and C program under 64 bit windows 7
  • Javascript: parseInt() with trailing characters
  • SVG .end event not working?
  • position: fixed with margin: auto in IE9/10
  • Image disappears after page finished load
  • PDF page count using regex
  • How can I escape backslash in logstash grok pattern?
  • Background image does not show on iPhone/iPad
  • Javascript get plain text from server
  • chrome PDF viewer can't download file
  • Store specific data in variable from another variable with regex with PHP
  • Gradle test fails with NullPointerException
  • Api Gateway cannot allow Access-Control-Allow-Origin
  • Regarding client side code generation from WSDL
  • Slow performance in hybrid AngularJS and Angular application in Safari
  • Is there a chance to get -splash: work for SWT applications that require -XstartOnFirstThread?
  • Cursor in wrong place in contenteditable
  • Most efficient way to replace lowest list values in dataframe in R
  • Is it safe to drop the -webkit vendor prefix from the css3 border-radius yet?
  • Is there a way to set up a fallback for the formAction attribute in HTML5?
  • Problems with toDataURL HTML5 other ways to get canvas data?
  • PayPal API Listener Website Payments Standard URI
  • Jenkins Grails plugin does not list lastest versions of Grails
  • Using Generics on right hand side in Java 6?
  • Flash radiobutton: how do I get the selected radiobutton?
  • Repository Browser Only - \"Repository moved permanently to… please relocate”
  • Hide HTML elements without javascript, only CSS
  • AppleScript : find open tab in safari by name and open it
  • Is playing sound in Javascript performance heavy?
  • How to run “Deployd” on port 80 instead of port 5000 in webserver.
  • Could not find rake using whenever rails
  • Chrome doesn't support silverlight anymore? How to solve this?
  • Display issues when we change from one jquery mobile page to another in firefox
  • Is there any way to access browser form field suggestions from JavaScript?
  • Ajax jQuery multiple calls at the same time - long wait for answer and not able to cancel
  • Javascript convert timezone issue
  • ActionScript 2 vs ActionScript 3 performance
  • How can I estimate amount of memory left with calling System.gc()?
  • Apache 2.4 - remove | delete | uninstall
  • Memory offsets in inline assembly