import java.awt.event.*;

/**
 * Listeners for chess board squares.
 *
 * @author Jim Glenn
 * @version 0.1 12/3/2002
 */

public class SquareListener extends MouseAdapter
{
    /**
     * The applet this listener will resend event to.
     */

    private ChessApplet ca;

    /**
     * Coordinate of the square this listener will listen to.  The
     * coordinates are sent to the applet when events are resent.
     */

    private int row, col;

    /**
     * Creates a new listener that resends events to the given applet.
     * The coordinates of the square the new listener listens to are
     * also given as parameters.
     *
     * @param app the applet to resend events to
     * @param r the row index of the square the new listener will listen to
     * @param c the column index of the square the new listener will listen to
     */

    public SquareListener(ChessApplet app, int r, int c)
    {
	ca = app;
	row = r;
	col = c;
    }
    
    /**
     * Responds to mouse clicks by resending them to the applet.
     *
     * @param e ignored
     */

    public void mouseClicked(MouseEvent e)
    {
	ca.mouseClicked(row, col);
    }
}

