How to make JFrame exist independently without parent?(如何让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在没有父级的情况下独立存在?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何让JFrame在没有父级的情况下独立存在?
基础教程推荐
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- Struts2 URL 无法访问 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
