Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Doubt about dispose() method of JDialog

887417Sep 16 2011 — edited Sep 19 2011
Hi guys,

Consider the following code:
		MyDialog dialog = new MyDialog(parent);
		dialog.setVisible(true);

                // may the dialog was disposed before the following line gets executed
		dialog.getVariableValue();

		dialog.dispose();
Suppose the MyDialog extends JDialog and have a member variable which can be accessed by getVariableValue() method.

A dialog appears, enter something which is stored by a member variable of the MyDialog class. Then close the dialog by invoking dispose() method. After the dialog disappears, the next line dialog.getVariableValue() can get the entered value.

I thought that the dialog will be null after dispose() gets called, but actually not.
Is the current thread stopped at the line dialog.setVisible(true) and wait for the dialog to be closed?

Can anyone explain?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 17 2011
Added on Sep 16 2011
11 comments
1,990 views