//This is a bit of fun with some of the new 1.1 features. In particular,
//it uses an inner class (tomButton), JDK 1.1 event handling, and uses
//anonymous inner classes to create the event handlers.

import java.awt.*;
import java.awt.event.*;

public class tomFrame extends Frame
{
        //inner class 
        class tomButton extends Button
        {
                public tomButton(String caption)
                {
                setLabel(caption);

                }
        }

//tomFrame constructor
        public tomFrame()
        {
        tomButton tb = new tomButton("Bold Experiment");

        //anonymous inner class

        //ActionListener is the type of event handler used with buttons
        ActionListener al = new ActionListener()
                {
                //overrides the default actionPerformed() method
                public void actionPerformed(ActionEvent ae)
                        {
                        System.out.println("action event performed: " + ae);
                        }
                };

        //add actionListener to button
        tb.addActionListener(al);

        //same drill as above, except that WindowListener is the type
        //of event listener used with the Frame class (which inherits this
        //from the Window class.

        WindowListener wl = new WindowListener()
                {
                public void windowActivated(WindowEvent we)
                        {
                        System.out.println("window event: " + we);
                        }
                public void windowClosed(WindowEvent we)
                        {
                        System.out.println("window event: " + we);
                        }
                public void windowClosing(WindowEvent we)
                        {
                        System.out.println("window event: " + we);
                        System.exit(0); //leave
                        }

                public void windowDeactivated(WindowEvent we)
                        {
                        System.out.println("window event: " + we);
                        }
                public void windowDeiconified(WindowEvent we)
                        {
                        System.out.println("window event: " + we);
                        }
                public void windowIconified(WindowEvent we)
                        {
                        System.out.println("window event: " + we);
                        }
                public void windowOpened(WindowEvent we)
                        {
                        System.out.println("window event: " + we);
                        }

                };

        //add WindowListener to frame
        addWindowListener(wl);
        //add button to frame
        add(tb);




        }

        public static void main(String argv[])
        {
                tomFrame tf = new tomFrame();
                tf.setSize(100, 100);
                tf.show();
        }

}

