我有这个代码来运行JOptionPane对象
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");
}
}
然而,当我运行createDialog方法时没有任何反应,如何正确运行JOptionPane对象?
答案 0 :(得分: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);
}
}
使用JDialog显示您的窗口