If you call setVisible(true) on a modal dialog, code subsequent to this instruction will not run until the dialog is disposed and I'm wondering how is this done.
How do you prevent the EDT from proceeding with no other thread to notify it? And if the EDT is blocked, where does event handling for the dialog occur?
Well, this is a guess, but I'm assuming that the EDT isn't blocked, but the parent of the modal dialog simply ignores events. To see how it is implemented, see the source code for JDialog.
Stephan van Hulst
Joined: Sep 20, 2010
I just took a look at the code, and what happens, more or less, is the following:
When you show a modal dialog, it will block the "real" event dispatch thread, but it will start a new thread which deals with the event queue. This new thread will have a filter applied on it, which causes it to block events for the owner of the modal dialog, but deals with other events as it would normally.
When you dismiss the modal dialog, the new thread will stop, and the real event dispatch thread will continue running.
There are no new questions, but there may be new answers.
Joined: Jan 28, 2010
Hi Stephan thanks for your response. I suspected something like this. I'd like to see how this is written but I can't find where in the hierarchy this is implemented. Would you please tell me what method in what class did you look at?