Java JFrame optionDialog(String title, String text, String option1, String option2, int defaultOption, JFrame parentFrame)

Here you can find the source of optionDialog(String title, String text, String option1, String option2, int defaultOption, JFrame parentFrame)

Description

option Dialog

License

Open Source License

Declaration

public static int optionDialog(String title, String text, String option1, String option2, int defaultOption,
            JFrame parentFrame) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import javax.swing.JFrame;

import javax.swing.JOptionPane;

public class Main {
    public static int optionDialog(String title, String text, String option1, String option2, int defaultOption,
            JFrame parentFrame) {
        if (defaultOption < 1)
            defaultOption = 1;//from   w  w  w  .j  a va2  s  . c  om
        if (defaultOption > 2)
            defaultOption = 2;
        Object[] options = { option1, option2 };
        int n = JOptionPane.showOptionDialog(parentFrame, text, title, JOptionPane.YES_NO_CANCEL_OPTION,
                JOptionPane.QUESTION_MESSAGE, null, options, options[defaultOption - 1]);
        n = n + 1;
        return n;
    }
}

Related

  1. msgBox(JFrame frame, String title, String message)
  2. newDialog(JFrame owner, String title, JPanel content)
  3. newExitActionListener(final JFrame jFrame)
  4. newJFrame(Component c, String title, int w, int h)
  5. newModalDialog(JFrame owner, String title, JPanel content, JButton... buttons)
  6. packFrame(JFrame frame)
  7. packJFrameWindow(final JComponent comp)
  8. POPUP(JFrame frame, String message)
  9. popupError(JFrame parent, String title, String text)