Re: How to pass back a value from a window



Thank all,

Give me a lot of response. I newed a JDialog with a true modal value.
When click OK button, the dialog is setVisible(false).

I get the value by getResult() which defined in the window class
called. After getting the result, I dispose the dialog. It works well.

I appreciate your helpful suggestion and help!


Jeff wrote:
PJava wrote:
If you use JOptionPane.showInputDialog, it will pass back a string
value.

I have a JDialog window, but don't know how to pass back an object
after the window closed.

Please kindly give me some idea!

THANKS!!!

Assuming you have an OK button on your dialog that you are using to
close, in the event listener for the button use
myDialog.setVisible(false);

Then you can read the fields from the dialog, even though it is no
longer displayed, at any time. No need to pass the object, just read
it.
/js

.