Hi all,
In my Swing application I have a JButton on a JPanel that tells the program
to save a large array of data to disk. The process takes about 10 seconds,
so I pop up a simple JDialog showing how far along the process is. I'm
creating and showing the JDialog, then using SwingWorker() to do the save as
a background thread so the UI thread doesn't hang. Inside construct() I'm
updating a JLabel on the JDialog with some descriptive text about where it
is in the process. This works perfectly.
But I have a bit of a Catch-22 situation. Since the JDialog isn't modal,
it's still possible to click the JButton "underneath" the JDialog and start
*another* thread doing exactly the same thing in parallel. Not good.
However, if I set the JDialog to be Modal, the main thread stops when
.setVisible() is called, of course. So the background thread never gets
started.
Any suggestions? Is there a better way to go about this?
Thanks much,
Leif

Signature
Leif Bloomquist
leif (at) schema factor (dot) com
http://home.ica.net/~leifb/
"Once secure, saturate the area with plasma mortars and spicy barbecue
sauce."
Knute Johnson - 29 May 2006 22:09 GMT
> Hi all,
>
[quoted text clipped - 18 lines]
> Thanks much,
> Leif
Sure, start the background worker thread and then open your modal dialog.

Signature
Knute Johnson
email s/nospam/knute/
Andrey Kuznetsov - 29 May 2006 22:45 GMT
>> But I have a bit of a Catch-22 situation. Since the JDialog isn't modal,
>> it's still possible to click the JButton "underneath" the JDialog and
[quoted text clipped - 11 lines]
>
> Sure, start the background worker thread and then open your modal dialog.
or disable your button instead
Andrey

Signature
http://uio.imagero.com Unified I/O for Java
http://reader.imagero.com Java image reader
http://jgui.imagero.com Java GUI components and utilities
Leif Bloomquist - 30 May 2006 14:35 GMT
> Sure, start the background worker thread and then open your modal dialog.
Ah! I should have thought of that. This worked perfectly, of course. Many
thanks!