This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Disposing of Objects Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Disposing of Objects" Watch "Disposing of Objects" New topic
Author

Disposing of Objects

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

I would like a little info that I can't figure out from what I have been reading on GC.
If I have a JTabbedPane with 4 Tabs, and on tab #4 I have a JPanel with different SWING objects placed on the JPanel, if I call dispose() on the JPanel when removing that Tab #4 from the JTabbedPane, will it and all the objects that are contained within that JPanel be GC'd? Do I need to dispose() the Tab itself or is removing it sufficient?
How do I ensure that when I remove the Tab the JPanel and it's objects get GC'd?
BTW - I have a class that extends JPanel. And all it's objects are contained in that class.


GenRocket - Experts at Building Test Data
Chantal Ackermann
Ranch Hand

Joined: Sep 28, 2000
Posts: 508
hi Gregg,
an object is garbage collected when there is no reference pointing to it anymore (except for WeakReferences). So setting all references to your panel to null should do it. Concerning the tab: I don't know what you have to do, to be sure that the JTabbedPane releases the reference to the Tab that you want to dispose of. You might read through the source of JTabbedPane to find out?
Chantal
 
jQuery in Action, 2nd edition
 
subject: Disposing of Objects
 
Similar Threads
programe structure
The programe structure
Tab order in swing component
program sturcture
Design / Development Question