/Users/lyon/j4p/src/graphics/graph/ClosableFrame.java

1    package graphics.graph; 
2     
3    import java.awt.*; 
4    import java.awt.event.WindowAdapter; 
5    import java.awt.event.WindowEvent; 
6     
7    public class ClosableFrame extends Frame { 
8        public ClosableFrame() { 
9            this(""); 
10       } 
11    
12       public ClosableFrame(String title) { 
13           super(title); 
14           setBackground(Color.white); 
15           addWindowListener( 
16                   new CloseAdapter()); 
17       } 
18    
19       public static void main(String args[]) { 
20           ClosableFrame cf = new ClosableFrame("cutils.putils.cutils.putils.graphics.graph.graphics.graph.ClosableFrame"); 
21           cf.setSize(200, 200); 
22           cf.setVisible(true); 
23       } 
24    
25       private class CloseAdapter extends WindowAdapter { 
26           public void windowClosing(WindowEvent e) { 
27               setVisible(false); 
28               dispose(); 
29           } 
30       } 
31   }