Re: SwingWorker.execute() does nothing



John W Kennedy wrote:
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

No, "modal dialog" means that the main window will not receive UI events while it is displayed.

The behavior you are describing is neither obvious from perusing the Swing tutorial nor obvious from the industry-wide definition of "modal dialog".

The execute(), therefore, was never even reached

But this was not obvious on casual inspection. The user's first encounter with this is going to look like "execute() didn't do anything". Indeed, did look like that.

Please stop posting to this thread now. The problem has been solved and continuing to post here can therefore serve no useful purpose related to the solving of that problem.
.


Quantcast