Re: SwingWorker.execute() does nothing



Ben Phillips wrote:

Thomas Kellerer wrote:
Ben Phillips, 08.10.2008 08:45:
I've got a strange app hang. A particular button click pops up a modal
"Please Wait" dialog, then constructs a SwingWorker implementation and
calls execute() on it. The done() method removes the dialog.

When you call setVisible(true) on a modal dialog, your code will stop
until the dialog is closed. So if you call SwingWorker.execute() after
setVisible(true) the execute() will not be called until the dialog is
closed.

Really? What idiot made that boneheaded design decision --

What do you mean, boneheaded? It's what modal Dialogs do.

What /is/ boneheaded is using a component and assuming you know what it does and
how it works. Then, when you find out your assumptions were wrong, blaming the
component for not working how you expected.

and,
moreover, didn't document it anywhere?

It is documented under the setVisible() method of Dialog (from which JDialog
derives) in the API docs, where it says:

Notes for modal dialogs.

* setVisible(true): If the dialog is not already visible, this call will not
return until the dialog is hidden by calling setVisible(false) or dispose.

--
Nigel Wade
.