import java.awt.*; import java.awt.event.*; import javax.swing.*; public class TestFrame2 extends JFrame implements WindowListener { public TestFrame2 () { // Set the title, size and Window-closing event listener. setTitle ("Hello World Window"); setSize (500, 300); addWindowListener (this); // Make a panel instance and put that in the frame. TestPanel2 p = new TestPanel2 (); getContentPane().add(BorderLayout.CENTER, p); // Make the frame visible. setVisible (true); } // Implementation of WindowListener interface: public void windowClosing(WindowEvent e) { System.exit(0); } // Empty implementations of methods we don't need. public void windowOpened(WindowEvent e) {} public void windowClosed(WindowEvent e) {} public void windowIconified(WindowEvent e) {} public void windowDeiconified(WindowEvent e) {} public void windowActivated(WindowEvent e) {} public void windowDeactivated(WindowEvent e) {} }