0

I have this code to run a JOptionPane object

import import javax.swing.JOptionPane;
public class TheComboBoxes {
public static void main(String[] args) {
    JOptionPane optionPane = new JOptionPane(
            "The only way to close this dialog is by\n"
            + "pressing one of the following buttons.\n"
            + "Do you understand?",
            JOptionPane.QUESTION_MESSAGE,
            JOptionPane.YES_NO_OPTION);
    optionPane.createDialog("click");
}
}

however when i run the createDialog method nothing happens, how to i run the JOptionPane object properly?

IDKWhatImDoing
  • 137
  • 1
  • 13

1 Answers1

0
import javax.swing.JDialog;
import javax.swing.JOptionPane;
public class TheComboBoxes {
    public static void main(String[] args) {
        JOptionPane optionPane = new JOptionPane("The only way to close this dialog is by\n"
                + "pressing one of the following buttons.\n" + "Do you understand?", JOptionPane.QUESTION_MESSAGE,
                JOptionPane.YES_NO_OPTION);
        JDialog dialog = optionPane.createDialog("click");
        dialog.setVisible(true);
    }
}

Use the JDialog to show your window

Mamadou
  • 86
  • 1
  • 6