import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/*
 *		Created on Feb 13, 2007 2:23:06 PM
 */

public class ListeningFrame extends JFrame {
   Color shapeColor;
   int x, y, width, height;
   Point location;
   
   public ListeningFrame (String name) {
      super (name);
      setSize (300, 300);
      setDefaultCloseOperation (EXIT_ON_CLOSE);

      shapeColor = Color.BLACK;
      x = y = 0;
      width = height = 0;
      location = getLocation();
      //anonymous class with two methods
      addWindoListener(new WindowAdapter()
      {
         //what happens when the window is closed
         public void windowClosing(WindowEvent e)
         {
           JOptionPane.showMessageDialog(ListeningFrame.this,"I'll miss you.");
         }
         //what happens when the window is opened
         public void windowOpening(WindowEvent e)
         {
            shapeColor = Color.blue;
            height = getHeight();
            width = getWidth();
         }
      });

    


      setVisible (true);
   }
   
   public void paint (Graphics g) {
      super.paint (g);
      g.setColor (shapeColor);
      g.fillRect (x, y, width, height);
   }

   public static void main (String []args) {
      new ListeningFrame ("Lab 7");
   }
}
