// Exercise10_4.java: The Maze problem
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class Exercise10_4 extends JApplet
  implements MouseListener
{
  // Point is a Java object for representing points in a plane.
  // p.x and p.y are the x and y coordinates.
  private Point p = new Point(0, 0);

  // set the title for the window.  The title TestEvent will
  // be displayed at the bar of the wondow.
  public void init()
  {
    addMouseListener(this);
  }

  // Main method
  public static void main(String[] args)
  {
    // Create a frame
    JFrame frame = new JFrame(
      "Exercise 10.4");

    // Create an instance of MortgageApplet
    Exercise10_4 applet = new Exercise10_4();

    // Add the applet instance to the frame
    frame.getContentPane().add(applet, BorderLayout.CENTER);

    // Invoke init() and start()
    applet.init();
    applet.start();

    // Display the frame
    frame.setSize(300, 300);
    frame.setVisible(true);
  }

  public void mousePressed(MouseEvent e)
  {	}

  public void mouseReleased(MouseEvent e)
  {	}

  public void mouseEntered(MouseEvent e)
  {	}

  public void mouseExited(MouseEvent e)
  {	}

  // When mouse is clicked, the mouse pointer location is
  // captured in the point p.
  public void mouseClicked(MouseEvent e)
  {
    p.x = e.getX();
    p.y = e.getY();
    repaint();
  }

  // Draw a small solid square around the point
  public void paint(Graphics g)
  {
    g.drawString("("+p.x+", "+p.y+")", p.x, p.y);
  }
}
