tags:

views:

193

answers:

1

I have a small dialog that is independent from the rest of the whole project. There are several threads that can call this dialog.

The problem is a modal JDialog that shows the progress of the current task. My dialog will be opened behind the progress dialog. There is no possibility to get this dialog.

Is it possible to get the current active dialog so that I can use them as the parent of my new dialog?

A: 

A few points:

You state that several threads can potentially call this dialog, whereas for a Swing application you should ensure that the Event Dispatch Thread is the only thread that launches this dialog.

If you follow this constraint it is more likely that you'll have a reference to the already displayed progress dialog and will therefore be able to use it as the dialog parent.

It sounds like you potentially need to rearchitect your application. Typically you might invoke a SwingWorker to perform the background task, which would "publish" progress back onto the Swing thread, which would then update the progress dialog.

Another tip: You can use the toFront() method on Window to bring a dialog to the front of the screen, although this doesn't seem to be the crux of your problem.

Adamski