Meaningless Drivel is fun!*
The moose likes Swing / AWT / SWT and the fly likes Dialogs lose focus when minimizing and restoring the application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Dialogs lose focus when minimizing and restoring the application" Watch "Dialogs lose focus when minimizing and restoring the application" New topic
Author

Dialogs lose focus when minimizing and restoring the application

Jeff Chang
Greenhorn

Joined: Aug 23, 2001
Posts: 23
Hi,
I have a problem as below:
Dialog(s) lose focus when minimizing and restoring the application and therefore fall behind the main application window. The user is required to find and close the dialog(s)
before continuing with any other operation.
This occures when the user clicks the Show Desktop icon in the task bar. Restore the application by clicking on the application icon in the task bar.
Observe: The dialog has fallen behind the main application window. Must presee Alt + Tab keys to restore focus on the dialog.
Anybody knows how to solve such a problem? Thanks anyway.
Jeff
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

How do you minimize the App with a Dialog window open? When my dialogs open, I can't do anything until I lose the Dialog. That includes minimizing any part of my App.
Also, are you using AWT or SWING.
------------------
Happy Coding,
Gregg Bolinger


GenRocket - Experts at Building Test Data
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Oh, sorry about that last replay. I just figured out what you meant. Sorry about that. I am looking into it though.

------------------
Happy Coding,
Gregg Bolinger
Govind Kurup
Greenhorn

Joined: Sep 04, 2001
Posts: 1
Hello,
Have you used "null" as the parameter for
showSaveDialog(Component parent)/ showOpenDialog(Component parent) function.
If so then replace null with the main JFrame class instance (assuming your main class is a JFrame).
It should work..
Bye
Originally posted by Jeff Chang:
Hi,
I have a problem as below:
Dialog(s) lose focus when minimizing and restoring the application and therefore fall behind the main application window. The user is required to find and close the dialog(s)
before continuing with any other operation.
This occures when the user clicks the Show Desktop icon in the task bar. Restore the application by clicking on the application icon in the task bar.
Observe: The dialog has fallen behind the main application window. Must presee Alt + Tab keys to restore focus on the dialog.
Anybody knows how to solve such a problem? Thanks anyway.
Jeff

Dima Riabin
Greenhorn

Joined: Jan 05, 2011
Posts: 16

Hi, I just had the same problem with somebody's code, I inheritted. The way I solved it was that when the dialog was opened, the dialog is a class extending from JDialog and the previous programmer was instantiating with the constructor taking JFrame as a parameter. The frame object was a new object for some reason. That's why dialog had no connection with your main application window.
You have to give "this" instead of a new JFrame. Provided your main application window is a JFrame.
Dima Riabin
Greenhorn

Joined: Jan 05, 2011
Posts: 16

Govind Kurup wrote:Hello,
Have you used "null" as the parameter for
showSaveDialog(Component parent)/ showOpenDialog(Component parent) function.
If so then replace null with the main JFrame class instance (assuming your main class is a JFrame).
It should work..


Thanks. That was exactly what it was. There was null passed as a parent parameter....
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Dialogs lose focus when minimizing and restoring the application
 
Similar Threads
Modal dialog box and request focus
Progress Bar
Two focused window at the same time
JDialog --PLS HELP !!
2 way Communication between Java and native methods