Computer Science Canada

JOptionPane help

Author:  Williamarf [ Fri Dec 21, 2012 6:03 pm ]
Post subject:  JOptionPane help

How do I set functionality for the YES_NO_CANCEL_OPTION?

Author:  Panphobia [ Fri Dec 21, 2012 6:07 pm ]
Post subject:  RE:JOptionPane help

What do you mean by set functionality?

Author:  Panphobia [ Fri Dec 21, 2012 6:09 pm ]
Post subject:  RE:JOptionPane help

Here is some wonderful info on the swing class on oracle http://docs.oracle.com/javase/tutorial/uiswing/components/dialog.html

Author:  Williamarf [ Fri Dec 21, 2012 6:10 pm ]
Post subject:  RE:JOptionPane help

By "set functionallity" I mean get them to do something.

Author:  Panphobia [ Fri Dec 21, 2012 6:11 pm ]
Post subject:  RE:JOptionPane help

http://docs.oracle.com/javase/tutorial/uiswing/components/dialog.html

Author:  Williamarf [ Fri Dec 21, 2012 6:25 pm ]
Post subject:  RE:JOptionPane help

Yes it is a great site but it does not tell me anything about getting the yes no buttons to do anything.

Author:  Panphobia [ Fri Dec 21, 2012 6:34 pm ]
Post subject:  Re: JOptionPane help

It actually gives you all the information you need, you just weren't looking into it this is what you were looking for I think
code:
int n = JOptionPane.showConfirmDialog(
    null,
    "Would you like green eggs and ham?",
    "An Inane Question",
    JOptionPane.YES_NO_OPTION);

Author:  Williamarf [ Sun Dec 23, 2012 1:22 am ]
Post subject:  RE:JOptionPane help

no. I saw that. but it only tells me how to get the buttons not how to get the yes no buttons to do anything.

Author:  [Gandalf] [ Sun Dec 23, 2012 4:49 am ]
Post subject:  RE:JOptionPane help

Since JOptionPane dialogs are all modal, you just take the value returned by the dialog and do what you want after it. The button or option selected is returned from the show dialog function (i.e. n in the above example).


: