import java.awt.*;

public class FontUser extends java.applet.Applet
{
   Label lTitle = null, lTag = null, lInfo = null;
   TextField tfCoords = null;
   Panel pActive = null;

   public void init()
   {
      setLayout(new GridLayout(0, 1));

      lTitle = new Label("A Demonstration");
      lTitle.setFont(new Font("Helvetica", Font.BOLD, 16));
      add(lTitle);

      Panel p = new Panel();
      p.setLayout(new GridLayout(0, 2));

      lTag = new Label("Coordinates");
      lTag.setFont(new Font("Dialog", Font.BOLD, 12));
      p.add(lTag);

      tfCoords = new TextField();
      tfCoords.setFont(new Font("Courier", Font.PLAIN, 12));
      tfCoords.setEditable(false);
      p.add(tfCoords);

      add(p);

      lInfo = new Label("Move your mouse around in the gray area below...");
      lInfo.setFont(new Font("Dialog", Font.PLAIN, 10));
      add(lInfo);

      pActive = new Panel();
      pActive.setBackground(Color.lightGray);
      add(pActive);
   }

   public Insets insets()
   {
      return new Insets(10, 10, 10, 10);
   }

   public boolean handleEvent(Event e)
   {
      if (e.target == pActive && e.id == Event.MOUSE_MOVE)
      {
         tfCoords.setText(e.x + " " + e.y);
         return true;
      }
      else if (e.target == pActive && e.id == Event.MOUSE_EXIT)
      {
         tfCoords.setText("");
         return true;
      }

      return super.handleEvent(e);
   }

   public static void main(String [] args)
   {
      Frame f = new Frame("A Clever User of Fonts");

      FontUser fu = new FontUser();

      fu.init();

      f.add("Center", fu);

      f.pack();
      f.show();
   }
}
