如何在没有父级的情况下使JFrame独立存在? [英] How to make JFrame exist independently without parent?
问题描述
我正在制作一个小应用程序。从一个JFrame,我调用另一个JFrame。现在,即使我关闭了父JFrame,我希望这个子JFrame独立存在。有什么方法可以做到这一点吗?或者这是不可能的?请帮我。如果您需要我发布代码,请告诉我。
I am making a small application. From one JFrame, I am calling another JFrame. Now, I want this child JFrame to exist independently even after I've closed the parent JFrame. Is there any way I can do this? Or is this just NOT possible? Please help me. Let me know if you need me to post the code.
谢谢。
推荐答案
在每个JFrame上,使用#setDefaultCloseOperation 到以下内容:
On each JFrame, set the default close operation with #setDefaultCloseOperation to the following:
- DISPOSE_ON_CLOSE
当你按下框架的关闭按钮时,它只会关闭它,而另一个将继续它的生命直到它关闭。
When you press the close-button of the frame, it will only close it and the other will continue its life until it is closed.
注意:我建议避免使用多个框架,而是尝试使用Tabs,它可以提供更好的用户体验。
Note: I would recommend to avoid multiple Frames and rather try to use Tabs, it provides a better user experience.
这篇关于如何在没有父级的情况下使JFrame独立存在?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!