001    package org.rakeshv.gui;
002    
003    import javax.swing.*;
004    import java.awt.event.*;
005    
006    public class CloseableFrame extends JFrame 
007    {
008      public CloseableFrame() 
009      {
010        addWindowListener(
011            new WindowAdapter() 
012            {
013              public void windowClosing(WindowEvent e) 
014              {
015                dispose();
016                System.gc();
017                System.exit(0);
018              }
019            }
020        );
021      }
022    
023      public CloseableFrame( String string ) 
024      {
025        super( string );
026    
027        addWindowListener(
028            new WindowAdapter() 
029            {
030              public void windowClosing(WindowEvent e) 
031              {
032                dispose();
033                System.gc();
034                System.exit(0);
035              }
036            }
037        );
038      }
039    }