Results 1 to 3 of 3
  1. #1
    mandrake446 is offline Member
    Join Date
    Nov 2007
    Posts
    8
    Rep Power
    0

    Default Yes/No confirm dialog box

    I was just wondering how to creat a "yes / no" dialog box. I can create a dialog boxes with the choice for "ok/ 'x' in the corner" its just

    import javax.swing.JOptionPane; //before the class declaration

    JOptionPane.showMessageDialog(null, "Are you an idiot?"); //in the class



    i was just wondering if someone could show me the code for a "yes/no" option dialog box.

    Thanks,
    Mandrake




    edit: What i'm trying to do is use a yes/no dialog box as the control for a loop where if "yes" is selected the loop will run though again, but terminates if "no" is selected.

    example:

    Do you want more money?

    Yes: (loop causes your taxes to raise)
    yes: (loop causes your taxes to raise)
    yes: (loop causes your taxes to raise)

    No:(loop terminates, not raising your taxes)
    Last edited by mandrake446; 12-08-2007 at 05:55 AM.

  2. #2
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    9

    Default

    Java Code:
    import javax.swing.JOptionPane;
    
    public class OptionLoop {
        public static void main(String[] args) {
            System.out.printf("JOptionPane.YES_OPTION    = %d%n" +
                              "JOptionPane.NO_OPTION     = %d%n" +
                              "JOptionPane.CLOSED_OPTION = %d%n",
                               JOptionPane.YES_OPTION,
                               JOptionPane.NO_OPTION,
                               JOptionPane.CLOSED_OPTION);
            int more = JOptionPane.YES_OPTION;
            do {
                more = JOptionPane.showConfirmDialog(null, "Want more?", "Input",
                                          JOptionPane.YES_NO_OPTION);
                System.out.println("more = " + more);
            } while(more == JOptionPane.YES_OPTION);
        }
    }

  3. #3
    mandrake446 is offline Member
    Join Date
    Nov 2007
    Posts
    8
    Rep Power
    0

Similar Threads

  1. Run As dialog and Plugin Help
    By menelaosbgr in forum Eclipse
    Replies: 0
    Last Post: 03-25-2008, 03:21 AM
  2. Example - File Dialog
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 03-01-2008, 10:11 PM
  3. Example of SWT Dialog
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-09-2008, 12:01 PM
  4. Dialog Box
    By uncopywritable in forum New To Java
    Replies: 2
    Last Post: 07-30-2007, 12:42 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •