How to make JFrame exist independently without parent?

一笑奈何 提交于 2019-12-20 02:57:13

问题


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.

Thanks.


回答1:


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.

Note: I would recommend to avoid multiple Frames and rather try to use Tabs, it provides a better user experience.




回答2:


Yeah it is definitely possible, just make sure the original frame isn't set to exit the application on close.

The second frame exists independently from the first, and you don't necessarily have to link the two if you don't want to.



来源:https://stackoverflow.com/questions/11473391/how-to-make-jframe-exist-independently-without-parent

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!