How can I terminate resources in a safe way when JFrame is about to close? - If I put terminate() in the a finally block it runs before windowClosing(). - If I put terminate in windowClosing() it can't be accessed from an inner class. I am aware that I shouldn't use finalize(), but I don't know from where (and how) should I call my terminate() method. Is there an "official" way to **close a JFrame with windowClosing() and do some tasks** (save data, close streams) **before** the program **exits**? **Where should I put my terminate() method?** public class Test extends …

Member Avatar
Member Avatar
+0 forum 2

[CODE]class A extends B { C ob1=new C(); D ob2=new D(); protected void finalize() { System.out.println("Finalizing A"); super.finalize(); } public static void main(String ss[]) { new A(); System.gc(); } }[/CODE] Though System,gc() doesn't guarantee the running of finalization, my question is if the JVM is able to run the finalizations at the time of call to gc(), what will be the order of execution of the finalizations for the classes A,B,C,D (assuming that all have finalizations with a code similar to that of A's and that apart from A, none of the classes explicitly inherit).

Member Avatar
Member Avatar
+0 forum 9

The End.