Re: SwingWorker.execute() does nothing



Ben Phillips wrote:
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.

Which is exactly why your mainline code stopped dead at the setVisible(true). That's what "modal dialog" /means/; the dialog is alive, while the code that displayed it is frozen, waiting for the dialog to be dismissed. The execute(), therefore, was never even reached, and has bloody nothing at all to do with it.

--
John W. Kennedy
"You can, if you wish, class all science-fiction together; but it is about as perceptive as classing the works of Ballantyne, Conrad and W. W. Jacobs together as the 'sea-story' and then criticizing _that_."
-- C. S. Lewis. "An Experiment in Criticism"
.