• Post Reply Bookmark Topic Watch Topic
  • New Topic

"destroying" a JPanel

 
Deb Tomlin
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anyone know if there is a way to completely destroy a JPanel?

When a JDialog is destroyed with dispose() everything is cleaned up nicely. Is there a way to do something similar with other components such as a JPanel?
 
Joe Ess
Bartender
Posts: 9361
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The reason JDialog has a dispose() method is that JDialog has a native peer, that is, some windowing component attached to the native operating system. These native peers exist outside the JVM so the garbage collector will not free them. It is up to us to do it manually. JPanel has no native peer so it is not necessary to manually dispose of its resources. Set all your references to it to null and it will get cleaned up automatically.
 
Deb Tomlin
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a million for the response Joe! I've got it working now. I found some references that were not getting cleaned up and it has fixed my problem.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!