关闭窗口-但不要停止程序-JAVA [英] Close window - but don't stop program - JAVA

查看:76
本文介绍了关闭窗口-但不要停止程序-JAVA的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的程序中,如果有动作,它将打开一个窗口.在此窗口中填写信息并输入按钮后,该窗口为dispose().

In my program it opens a window if an action is happened. After I have filled out information in this window, and entered a button, the window dispose().

该窗口是在主程序之外的程序中拾取的,但是当我关闭该窗口时,我的主程序将停止.如何防止这种情况发生?

The window is picked up in a program outside my main program, but when I close this window, my main program stops. How can I prevent this from happening?

感谢您的帮助!

推荐答案

  1. 您可以将第二帧的 defalaultCloseOperation 属性设置为 DO_NOTHING_ON_CLOSE DISPOSE_ON_CLOSE

甚至不使用两个框架.使用模式 JDialog 代替辅助框架.有关更多信息,请参见如何使用对话框.阅读有关模式的更多信息.要获得良好的阅读效果,请参见使用多个JFrame,良好/不良做法?

Don't even use two frames. Use a modal JDialog instead for a secondary frame. See more at How to Use Dialogs. Read more about Modality. And for a good read, see The Use of Multiple JFrames, Good/Bad Practice?

忘记数字1,直接转到2.

Forget about number 1. and go straight to 2.

这篇关于关闭窗口-但不要停止程序-JAVA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆