【问题标题】:how to run JOptionPane object如何运行 JOptionPane 对象
【发布时间】:2016-11-06 23:23:47
【问题描述】:

我有这段代码来运行一个 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 对象?

【问题讨论】:

标签: java joptionpane


【解决方案1】:
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 显示您的窗口

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多