在 javadoc 上,HIDE_ON_CLOSE 默认选项说明了这一点
Automatically hide the frame after invoking any registered WindowListener objects.
“隐藏”是什么意思?现实对象被销毁或只是隐藏并继续使用资源?
最佳答案
On javadoc, the HIDE_ON_CLOSE default option says that
Automatically hide the frame after invoking any registered WindowListener objects.
Now what it means "HIDE"? the realtive object is destroyed or just hide and continue using resources?
HIDE_ON_CLOSE
与JFrame.setVisible(false)
相同,然后
JFrame
仅隐藏,不可见,不会被JFrame 以某种方式破坏(
在屏幕上再次可见并且没有任何变化JFrame.dispose()
也是如此)。 setVisible(true)
编辑
@giozh wrote and if i want to destroy the jframe (without close the entire application)?
默认情况下没有任何理由,因为默认情况下没有理由创建另一个
JFrame
,不要那样做,使用CardLayout
(与JFrame.pack()
如果需要更改屏幕上的JFrames
大小)and all those
Object
stays and increasing JVM memory,never will be CG'ed
,那么JFrame.HIDE_ON_CLOSE
、JFrame.DISPOSE_ON_CLOSE
或JFrame.setVisible(false)
之间的 JVM 内存没有显着差异(在您讨厌
CardLayout
的情况下)您可以从JFrames ContentPane
中删除所有JComponents
,然后添加新的JComponents
,设置LayoutManager
和最后一行代码(在对已可见的JFrame
进行所有更改后)将是JFrame。(重新)validate();
、JFrame.repaint();
和JFrame.pack();
关于java - JFrame 和 setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17743486/