wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes Bringing specific Jdialog to front when having multiple jdialogs in one application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Bringing specific Jdialog to front when having multiple jdialogs in one application" Watch "Bringing specific Jdialog to front when having multiple jdialogs in one application" New topic
Author

Bringing specific Jdialog to front when having multiple jdialogs in one application

N A Khan
Greenhorn

Joined: Dec 23, 2013
Posts: 4
I have multiple JDialogs in my application stored in a map. These JDialogs are all have


When these dialogs are out of focus and I want to bring a specific JDialog toFront all JDialogs come toFront. I want the specific Jdialog to come to front and want the other JDialogs to remain in back.


This code brings all the JDialogs toFront having the specificJDialog on top of the stack.


This Method only returns a HashMap nothing else.
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2380
    
    7

Welcome

Is there a question in your post?


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7 OCPWCD5
N A Khan
Greenhorn

Joined: Dec 23, 2013
Posts: 4
Thanks,

Yes, actually I have explained the scenario and my question was: How can I bring the specific JDialog to front while other JDialogs in the map remains in back?
N A Khan
Greenhorn

Joined: Dec 23, 2013
Posts: 4
Hi Everyone,
I found a solution to my problem I think it is worth sharing it.

Solution: Creating multiple JDilogs in an application with default constructor i.e. will result in a shared frame as the parent of each JDialog which will cause these kind of problems. So I used the overloaded constructor to have separate parent for each JDialog and that solved my problem.

Thanks!
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

You might consider "new JDialog(null)" instead -- the documentation says that this is the only way to produce an "unowned" JDialog. It's possible that unowned JDialogs would act the way you want them to act, and then you wouldn't have to create the extra JFrame objects which you are now creating. Not that they are a big problem, but they are a solution which merits a comment to explain to future readers of the code why it was done.
N A Khan
Greenhorn

Joined: Dec 23, 2013
Posts: 4
Paul Clapham wrote:You might consider "new JDialog(null)" instead -- the documentation says that this is the only way to produce an "unowned" JDialog. It's possible that unowned JDialogs would act the way you want them to act, and then you wouldn't have to create the extra JFrame objects which you are now creating. Not that they are a big problem, but they are a solution which merits a comment to explain to future readers of the code why it was done.


"new JDialog()" and "new JDialog(null)" both are internally calling the overloaded constructor "new JDialog(null, false)" which means they have no difference, they do create "unowned" JDialogs but doesn't solve the original problem.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Thanks for the feedback. Looks like the solution you found is indeed the solution for your problem, then.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Bringing specific Jdialog to front when having multiple jdialogs in one application