Win a copy of Murach's MySQL this week in the JDBC and Relational Databases forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Annoying quirk with JDialog on Windows 7

 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Mark Williams
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Glad to know that the solution was so simple!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic