【发布时间】:2016-05-07 07:35:45
【问题描述】:
我的JFrame 的项目菜单About 是JDialog,可以通过一个but 按钮关闭,如下所示:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
aboutDialog.this.dispose();
}
有时当我点击JDialog的关闭按钮时,它实际上关闭了整个程序。
我试过了:
aboutDialog.this.setvisible(true)
aboutDialog.this.setDefaultCloseOperation(EXIT_ON_CLOSE);
aboutDialog.this.setDefaultCloseOperation(HIDE_ON_CLOSE);
aboutDialog.this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
但它没有用,有什么想法吗?
【问题讨论】:
-
关于Dialog.this.setDefaultCloseOperation(EXIT_ON_CLOSE)?
-
sometimes when I click on the close button of the JDialog, it actually closes the entire program.- 如果对话框是您的应用程序中唯一打开的窗口,则会发生这种情况。