前言:这是我做的第一个真正的摇摆程序。
我有一个摇摆程序,其中一个 JButton 应该退出程序。该按钮触发 this.dispose();。当我单击此 JButton 时,它确实使窗口完全消失,但查看调试器,程序本身仍在运行。
我的主要方法只包括:
public static void main (String[] args)
{
java.awt.EventQueue.invokeLater(new Runnable()
{
public void run()
{
new StartupGui().setVisible(true);
}
});
}
我的退出按钮看起来像操作按钮看起来像:
private void exitButtonActionPerformed(java.awt.event.ActionEvent evt)
{
this.dispose();
}
我也试过这个退出按钮:
private void exitButtonActionPerformed(java.awt.event.ActionEvent evt)
{
java.awt.EventQueue.invokeLater(new Runnable()
{
public void run()
{
dispose();
}
});
}
在按下退出按钮后查看调试器,我看到以下内容(并且只有以下内容):
Daemon Thread [AWT-XAWT] (running)
Thread [AWT-Shutdown] (running)
Thread [AWT-EventQueue-0] (running)
Thread [DestroyJavaVM] (running)
Can anyone point me in the right direction as to why the program isn't shutting down after this point? I have done some googling but haven't gotten anywhere thus far. If you need any more information, just let me know
Thanks :)