import java.awt.*;
import java.awt.event.*;
class myFrame extends Frame
{
public void paint ( Graphics g )
{
g.drawString("Click the close button", 10, 50 );
}
}
class WindowQuitter extends WindowAdapter
{
public void windowClosing( WindowEvent e )
{
System.exit( 0 ); // what to do for this event--exit the program
}
}
public class GUItester
{
public static void main ( String[] args )
{
myFrame frm = new myFrame(); // construct a myFrame object
WindowQuitter wquit = new WindowQuitter(); // construct a listener for the frame
frm.addWindowListener( wquit ); // register the listener with the frame
frm.setSize( 150, 100 );
frm.setVisible( true );
}
}
|