且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从JFrame中删除面板后,如何处理JPanel

更新时间:2023-12-05 09:22:28

看看上面的代码,看起来似乎错过了一步。 remove()将从内容窗格中删除引用,但如果面板变量未设置为null或超出范围,则面板仍将具有引用,并且不会进行垃圾回收。

Looking at the code above, it looks like a step is missed. "remove()" will remove the reference from the content pane, but if the panel variable is not set to null or goes out of scope, the panel will still have a reference and it will not be garbage collected.