如何让JFrame在没有父级的情况下独立存在? [英] How to make JFrame exist independently without parent?

查看:26
本文介绍了如何让JFrame在没有父级的情况下独立存在?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个小型应用程序.从一个 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.

注意:我建议避免使用多个框架,而是尝试使用选项卡,这样可以提供更好的用户体验.

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

这篇关于如何让JFrame在没有父级的情况下独立存在?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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