java – JoptionPane ShowConfirmDialog

我有一个Java程序.当我运行程序时,它会给我一个GUI,我附上.

当我想关闭它时,它会提示确认对话框.如果我按下是按钮,它将使用System.exit()退出程序.

public static void main(String args[])
{
    ButtonTest app = new ButtonTest( );
    app.addWindowListener( 
        new WindowAdapter( )
        {
            public void windowClosing (WindowEvent e)
            {
                String message = " Really Quit ? ";
                String title = "Quit";
                int reply = JOptionPane.showConfirmDialog(null, message, title, JOptionPane.YES_NO_OPTION);
                if (reply == JOptionPane.YES_OPTION)
                {
                    System.exit(0);
                }

            }
        }
    );
}

如果我不想退出该计划,我该怎么办? System.continued()?

解决方法:

在这种情况下你不需要别的

上一篇:java – JOptionPane的几个输入字段?


下一篇:如何删除JOptionPane中的问号?