Re: SwingWorker.execute() does nothing



Nigel Wade wrote:
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.

It's not the behavior implied by the Swing tutorial, which says that there is exactly one event dispatch thread.

What /is/ boneheaded is [personal attacks that are not relevant here]

Please do not post unconstructive material, particularly personal attacks.

It is documented under the setVisible() method of Dialog (from which JDialog
derives) in the API docs

But that was not where I was looking. Since the problem appeared to be with SwingWorker.execute(), *that* was where I was looking. Obviously, documentation of a "gotcha" is not very useful if it is not located where the user is most likely to look for it.

Perhaps a note to this effect should be in *both* places, given the likelihood that someone will be showing a modal progress dialog or other such thing during a long-running operation, and given the natural tendency to want to pop up the dialog *first* and *then* start the operation.
.