> The Example2 pane pops up a JOptionPane that is documented
> to block the current thread.
This is an oversimplification. But first, JOptionPane is a subclass of
JDialog. And it is JDialog which contains the code for handling modal
window. For modal windows it checks if the current thread is the event
dispatching thread. If this is the case, it changes the event pump and
continues to pump events. It has to, otherwise no one could handle the
button events on the modal dialog. So you couldn't close a modal dialog :-)
The source code of JDialog is enlightening. You might want to spend a
few minutes and read through the parts related to modal window handling.
The source code comes with every Sun SDK in the file src.zip (or .jar in
older SDKs).
/Thomas
Babu Kalakrishnan - 18 Mar 2004 16:12 GMT
>> The Example2 pane pops up a JOptionPane that is documented
>> to block the current thread.
[quoted text clipped - 3 lines]
> The source code comes with every Sun SDK in the file src.zip (or .jar in
> older SDKs).
A small correction, Thomas. It is actually the code in the
java.awt.Dialog class that performs this magic - JDialog just inherits
it. The OP can refer to the show() method in the source code of
java.awt.Dialog for details.
BK
BPS - 18 Mar 2004 17:10 GMT
Thank you both so much! I will look at that code.
Cheers,
Benji