aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Annoying quirk with JDialog on Windows 7 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Annoying quirk with JDialog on Windows 7" Watch "Annoying quirk with JDialog on Windows 7" New topic
Author

Annoying quirk with JDialog on Windows 7

Mark Williams
Ranch Hand

Joined: Aug 01, 2008
Posts: 66
I don't do much Swing programming usually but I got to play with some at work recently. It's been a lot of fun but I've got this annoying little issue.

My app consists of a JFrame that opens up a modal JDialog to show progress of a long running task. When I alt-tab or switch to another window and then switch back to my program, the modal dialog comes to the top of the view but the parent JFrame does not come to the front. The parent JFrame remains behind the window I temporarily switched to while the modal JDialog comes right to the top. I expect to see JFrame come to the top along with the modal dialog.

This does not happen on my Linux/Gnome box, just on the Windows 7 boxes I have run the program on. Does anyone have any tips?
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4530
    
    5

Is the dialog constructed with the frame as its owner?

To get better help sooner, post a SSCCE (Short, Self Contained, Compilable and Executable) example that demonstrates the problem.


luck, db
There are no new questions, but there may be new answers.
Mark Williams
Ranch Hand

Joined: Aug 01, 2008
Posts: 66
I suspected that your question about constructing the dialog with the frame as the owner was going to lead me to the answer and it did. Thanks Darryl!
In my program, I subclassed JDialog (well actually the Eclipse WindowBuilder plugin did it for me) and didn't notice the constructors of JDialog that take a Frame as an argument.
After placing a call to the JDialog's constructor with the parent frame as an argument in my JDialog subclass's constructor, I got the behavior I expect.

Thanks!
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4530
    
    5

Glad to know that the solution was so simple!
 
Consider Paul's rocket mass heater.
 
subject: Annoying quirk with JDialog on Windows 7