lucy said:
I have some Java UI component, UITable...
it does not have any destruction methods?
Java Objects in general don't have destructors - the Garbage Collector function
built in to the JVM takes care of disposing off unused objects. If UITable is an
instance of a JTable as its name suggests, it is a Swing component, and doesn't
need anything special to be done before it is garbage collected. [There are a
few classes in Java (like e.g. java.awt.Window and its descendants) where you
need to explicitly call methods such as "dispose()" to ensure that all system
resources held by them through native code are released - but these are more of
an exception to the general rule]
I cannot remove it from my panel after it was shown... nor do I can remove
it from the memory completely and I believe I have some memory leakage?
Please help me remove it from the GUI and memory...
To remove it from its panel : "panel.remove(table)" should do the job (assuming
table refers to the instance of UITable and panel is the container into which it
was inserted. But make sure that you are removing the object from where you
added it. (For instance, you might have a JScrollPane which contains the Table,
and that might be the one you inserted into the panel. In this case you actually
need to remove the JScrollPane from the panel - not the table)
How are you determining that the table is not removed from memory ? (Hope it is
not by checking if a strong reference to it has become null). The Garbage
Collector will only dispose off unused objects - and in Java, "unused" refers to
objects that cannot be reached from any thread in your program. So to make sure
that it is released from memory, you must ensure that you don't hold any live
references to the table object.
BK