File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Dialog focus problem on java 7 and mac osx Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Dialog focus problem on java 7 and mac osx " Watch "Dialog focus problem on java 7 and mac osx " New topic

Dialog focus problem on java 7 and mac osx

Luis Goncalves

Joined: Jun 07, 2011
Posts: 4
Hi there,

I'm currently validating a swing application that runs on a browser (on an applets).
I came across with a problem for the java JRE 7 released by Oracle - this was not happening on Applet JRE 6 (1.6.0_33)

Every time I open a dialog within my application, that dialog comes to the front of the browser window but it does not request the focus as expected. THIS HAPPENS ONLY WHEN THE APPLET RUNS ON THE BROWSER.
Here is a small program to show the problem:

To run this code on an applet just create a jar file (let's call it test.jar) from the code. Then create a html file with the following content:

Once you run the html file, you'll see an grey area with a 'open dialog' button. If you press the button, a new dialog comes up with a JTextField and 3 buttons: 'Cancel', 'No' and 'Yes'. The button 'Yes' should be in focus by default, but that is not happening. Plus, even if you click in the JTextField, the field will not get the focus.
Again, this only happen when the applet run on the browser and only for Java 7 (which is the way I need to make it work).
java.vendor Oracle Corporation
java.version 1.7.0_07 Mac OS X
os.version 10.7.4

I used firefox 15 to test this.

Can someone with an applet computer confirm this? Any of you knows how can I solve this?

Thanks in advance
Darryl Burke

Joined: May 03, 2008
Posts: 5115

No idea about your specific problem*, but Applet initialization should be done in init() -- not start(), which is
called after the init method and each time the applet is revisited in a Web page.

Do you really want/need to add a new JPanel with a JButton and set it as the contentPane every time the Applet is revisited?

* edit: because I don't have a Mac, so I can't test nor investigate the behavior.

luck, db
There are no new questions, but there may be new answers.
Luis Goncalves

Joined: Jun 07, 2011
Posts: 4
That small program is just to show a problem that happens when you start a dialog from an applet running on the browser.

The actual application I'm validating is much different from this small example and is following the points you mention.

So, the way the applet is initialized is actually not that important. If instead of the start() you have the init() the result on the dialog - where the problem resides - is exactly the same.

I decided to post this problem in the forum in order to other mac users test and confirm this, which I believe is a JRE 7 - mac version - bug.

For those 'only' windows developers: THIS SAME PROBLEM DOES NOT HAPPEN ON WINDOWS.
I agree. Here's the link:
subject: Dialog focus problem on java 7 and mac osx
jQuery in Action, 3rd edition