Home arrow static arrow Java Programming [Archive] - return type of Dialog
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - return type of Dialog
This topic has 4 replies on 1 page.

Posts:27
Registered: 5/24/04
return type of Dialog  
Jun 18, 2004 9:08 AM



 
I want Dialog to return my own class when it is closed.
For example next dialog returns int, how to make dialog returning my own type?

//Custom button text
Object[] options = {"Yes, please",
"No, thanks",
"No eggs, no ham!"};
int n = JOptionPane.showOptionDialog(frame,
"Would you like some green eggs to go "
+ "with that ham?",
"A Silly Question",
JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.QUESTION_MESSAGE,
null,
options,
options[2]);

Thanks!
 

Posts:24,036
Registered: 2/3/03
Re: return type of Dialog  
Jun 18, 2004 9:12 AM (reply 1 of 4)



 
http://java.sun.com/docs/books/tutorial/uiswing/components/dialog.html
 

Posts:14,142
Registered: 99-04-02
Re: return type of Dialog  
Jun 18, 2004 9:13 AM (reply 2 of 4)



 
You can't. Well, you could presumably write your own showXxxDialog method in a subclass of JOptionPane, but why bother. The return values are going to be YES_OPTION, NO_OPTION, or CANCEL_OPTION, in that same order as you define the options. Presumably, that's 0, 1, or 2.
 

Posts:2,275
Registered: 10/18/03
Re: return type of Dialog  
Jun 18, 2004 9:15 AM (reply 3 of 4)



 
Presumably, that's
0, 1, or 2.

correct
 

Posts:27
Registered: 5/24/04
Re: return type of Dialog  
Jun 18, 2004 9:42 AM (reply 4 of 4)



 
So how would you return data to frame from dialog, if dialog is complicated and have many components like JTextField, JTextArea etc.. ?
 
This topic has 4 replies on 1 page.