Example usage for javax.swing JOptionPane QUESTION_MESSAGE

List of usage examples for javax.swing JOptionPane QUESTION_MESSAGE

Introduction

In this page you can find the example usage for javax.swing JOptionPane QUESTION_MESSAGE.

Prototype

int QUESTION_MESSAGE

To view the source code for javax.swing JOptionPane QUESTION_MESSAGE.

Click Source Link

Document

Used for questions.

Usage

From source file:JOptionPaneTest2.java

public static void main(String[] args) {
    JDialog.setDefaultLookAndFeelDecorated(true);
    int response = JOptionPane.showConfirmDialog(null, "Do you want to continue?", "Confirm",
            JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
    if (response == JOptionPane.NO_OPTION) {
        System.out.println("No button clicked");
    } else if (response == JOptionPane.YES_OPTION) {
        System.out.println("Yes button clicked");
    } else if (response == JOptionPane.CLOSED_OPTION) {
        System.out.println("JOptionPane closed");
    }/* w w  w  .j av a  2  s . c  om*/
}

From source file:Main.java

public static void main(String[] args) {
    String[] options = { "Button 1", "Button 2", "Button 3" };

    JOptionPane myOptionPane = new JOptionPane("Heres a test message", JOptionPane.QUESTION_MESSAGE,
            JOptionPane.YES_NO_OPTION, null, options, options[2]);
    JDialog myDialog = myOptionPane.createDialog(null, "My Test");
    myDialog.setModal(true);//from   w w  w .  ja  v  a  2  s.  c o  m

    inactivateOption(myDialog, options[1]);

    myDialog.setVisible(true);
    Object result = myOptionPane.getValue();
    System.out.println("result: " + result);

}

From source file:Main.java

public static void main(String[] args) {
    Object[] options = { "Option 1", "Option 2", "Option 3", "None of the above" };
    JComboBox optionControl = new JComboBox(options);
    optionControl.setSelectedIndex(3);/*from   ww  w  .  jav a 2  s.  co  m*/
    JOptionPane.showMessageDialog(null, optionControl, "Option", JOptionPane.QUESTION_MESSAGE);
    System.out.println(optionControl.getSelectedItem());

    String graphSelection = (String) JOptionPane.showInputDialog(null, "Choose from the following options...",
            "Choose From DropDown", JOptionPane.QUESTION_MESSAGE, null, options, options[3]);
    System.out.println(graphSelection);

    JOptionPane.showMessageDialog(null, optionControl, "Option", JOptionPane.QUESTION_MESSAGE);
}

From source file:BigValueJOptionpaneDialog.java

public static void main(String[] a) {
    JFrame frame = new JFrame();
    String bigList[] = new String[30];

    for (int i = 0; i < bigList.length; i++) {
        bigList[i] = Integer.toString(i);
    }/*from  w  w w.j  a v a 2  s.c  om*/

    JOptionPane.showInputDialog(frame, "Pick a printer", "Input", JOptionPane.QUESTION_MESSAGE, null, bigList,
            "Titan");

}

From source file:JOptionPaneTest3.java

public static void main(String[] args) {
    JDialog.setDefaultLookAndFeelDecorated(true);
    Object[] selectionValues = { "Pandas", "Dogs", "Horses" };
    String initialSelection = "Dogs";
    Object selection = JOptionPane.showInputDialog(null, "What are your favorite animals?", "Zoo Quiz",
            JOptionPane.QUESTION_MESSAGE, null, selectionValues, initialSelection);
    System.out.println(selection);
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Object[] options = { "Option 1", "Option 2", "Option 3", "Option 4", "Option 5", "Option 6", "Option 7",
            "None of the above" };
    JComboBox optionList = new JComboBox(options);
    optionList.setSelectedIndex(7);/*from w w  w.  j a  va  2s . c o m*/
    JOptionPane.showMessageDialog(null, optionList, "Title", JOptionPane.QUESTION_MESSAGE);
}

From source file:StringArrayOptionPopups.java

public static void main(String[] a) {
    JFrame frame = new JFrame();

    Icon blueIcon = new ImageIcon("yourFile.gif");
    Object stringArray[] = { "Do It", "No Way" };
    JOptionPane.showOptionDialog(frame, "Continue printing?", "Select an Option", JOptionPane.YES_NO_OPTION,
            JOptionPane.QUESTION_MESSAGE, blueIcon, stringArray, stringArray[0]);
}

From source file:MainClass.java

public static void main(String[] a) {
    Icon blueIcon = new MyIcon(Color.BLUE);
    Object stringArray[] = { "Do It", "No Way" };
    JOptionPane.showOptionDialog(new JDesktopPane(), "Continue printing?", "Select an Option",
            JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, blueIcon, stringArray, stringArray[0]);

}

From source file:AddingIconsToOptionPopups.java

public static void main(String[] a) {
    JFrame frame = new JFrame();
    Icon greenIcon = new ImageIcon("yourFile.gif");
    Icon redIcon = new ImageIcon("");
    Object iconArray[] = { greenIcon, redIcon };

    JOptionPane.showOptionDialog(frame, "Continue printing?", "Select an Option", JOptionPane.YES_NO_OPTION,
            JOptionPane.QUESTION_MESSAGE, null, iconArray, iconArray[1]);

}

From source file:JSliderOnJOptionPane.java

public static void main(final String[] args) {
    JFrame parent = new JFrame();

    JOptionPane optionPane = new JOptionPane();
    JSlider slider = getSlider(optionPane);
    optionPane.setMessage(new Object[] { "Select a value: ", slider });
    optionPane.setMessageType(JOptionPane.QUESTION_MESSAGE);
    optionPane.setOptionType(JOptionPane.OK_CANCEL_OPTION);
    JDialog dialog = optionPane.createDialog(parent, "My Slider");
    dialog.setVisible(true);/*w w  w.  j  a  v a2s  . c o m*/
    System.out.println("Input: " + optionPane.getInputValue());
}