The moose likes Swing / AWT / SWT and the fly likes Auto close of MessageDialog?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Auto close of MessageDialog?? " Watch "Auto close of MessageDialog?? " New topic

Auto close of MessageDialog??

Bikash Paul
Ranch Hand

Joined: Dec 04, 2001
Posts: 342
Hi all friends,
I want that my first Dialog should close automatically when my next Dialog pop up.My application requirement is i want to show two types of dialog one is when my work is going on "Please wait.." and another is when my work has beeen completed confimation message "Work has been completed".I want that when my work has beeen completed then my "Please wait.." dialog box should close automatically and confimation message dialog box should pop up.I tried with JOptionPane.showMessageDialog() with in loop but couldn't slove my problem.If it is not possible with MessageDialog then Is there any other way to do this.Plz guide me how i can do that.
Chris Shepherd
Ranch Hand

Joined: Jun 27, 2000
Posts: 286
what about using a ProgressMonitor with a ProgressBar.
You can also find usage info on them here.
I had to do something similar just recently and it worked out great.
Hope this helps.
[ February 21, 2003: Message edited by: Chris Shepherd ]
Nathan Pruett

Joined: Oct 18, 2000
Posts: 4121

I don't think it's going to work with JOptionPane, because, to quote from the API :

All dialogs are modal. Each showXxxDialog method blocks the current thread until the user's interaction is complete.

So if you had one thread doing processing and it launched a JOptionPane, all the processing would stop while the JOptionPane was up...

Here's something I threw together to illustrate what you're trying to do... the dialog itself contains the processing thread to show the spinning text, and it listens to the other thread that tells it when the work is done. That thread launches another thread to actually do the work...

Write once, run anywhere, because there's nowhere to hide! - /. A.C.
I agree. Here's the link:
subject: Auto close of MessageDialog??
It's not a secret anymore!