简体   繁体   English

关闭新打开的JFrame

[英]Closing newly opened JFrame

I'm developing a desktop application using NetBeans IDE. 我正在使用NetBeans IDE开发桌面应用程序。

1) I'm opening a new JFrame after a button click. 1)点击按钮后我打开一个新的JFrame。 While I'm closing any of the opened frames, both are getting closed. 当我关闭任何打开的帧时,两者都被关闭了。

2) And I want to update a new Tabbed JPanel on a JFrame after button click. 2)我想在点击按钮后在JFrame上更新新的Tabbed JPanel。 Thanks in advance. 提前致谢。

Probably you are using the wrong argument. 可能你使用的是错误的论点。 I guess for the JFrames that you want to close without closing the entire application you are doing: 我想对于你要关闭的JFrame而不关闭你正在做的整个应用程序:

jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

While to actually close only the desired frame without closing rest of the frames you need to do: 虽然实际上只关闭了所需的框架而没有关闭其他框架,但您需要这样做:

jFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

1) Why did you create lots of Top-Level Containers on Runtime, create only one JFrame and other would be JDialog(Modality) or JWindow(un-decorated), re-use that, 1)为什么你在运行时创建了很多顶级容器 ,只创建了一个JFrame,而另一个是JDialog(模态)或JWindow(未装饰),重用它,

2) really no battery included in my Magic Globe today, for better and sooner hepl you have to post here SSCCE 2)今天我的Magic Globe中真的没有电池,为了更好,更快,你必须在这里发布SSCCE

I want to update a new JTabbedPane on a JFrame after the button click. 我想在单击按钮后在JFrame上更新新的JTabbedPane

You can just update via a reference to the tab's JPanel and call repaint() , but sooner or later you should consider the Model–View–Controller pattern. 您可以通过对选项卡的JPanel的引用进行更新并调用repaint() ,但迟早您应该考虑模型 - 视图 - 控制器模式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM