aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes JDialog Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JDialog" Watch "JDialog" New topic
Author

JDialog

aymane chetibi
Ranch Hand

Joined: Apr 12, 2006
Posts: 175
Hello all,

I want to create a dialog and then let the user chooses among three options, then return the option choosen to the method that showed the dialog.

I created the dialog, now I don't know how to get back what the use choses
my code looks smthing like that:
Nicky Eng
Ranch Hand

Joined: Mar 26, 2005
Posts: 378
your 3 option are checkbox or radio type?


From NickyEng
Diploma in Computer Studies
SCJP 1.4
SCWCD 1.4
Formula 1 app by Maxis (Playbook)
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
one of the ways:
include a method in the dialog to return the selection (object, int, whatever).
make the dialog modal, so the method does not return until the dialog closes
[object?] selection = new dialog(name).getSelection();
aymane chetibi
Ranch Hand

Joined: Apr 12, 2006
Posts: 175
I got your point. but how can I make the model that way ?
and the options are just buttons!
(should I also, do smthing like that at the end of the action of the buttons: System.exit(1))

thanks!!!

regards,
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
if the options are just buttons, have you looked at
JOptionPane.showOptionDialog(...)

here's a simple demo
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JDialog