import java.awt.*;import java.awt.event.*;import javax.swing.event.*;import javax.swing.*;/** An instance is a JPanel of size (WIDTH,HEIGHT), which    is green or red depending on whether the sum of the    parameters of the constructor is even or not. Clicking    on the square produces a pink disk on it; click again    and the pink disk goes away. The JPanel is used only    as a graphics pane; no components are added to it.  */public class Square extends JPanel {	public static final int HEIGHT= 50;  // height and 	public static final int WIDTH=  50;  // width of square		private int x, y; // Coordinates of square on board	private boolean hasDisk= false; // = "the square has a pink disk"		/** Constructor: a square at (x,y) */	public Square(int x, int y) {	    this.x= x; this.y= y;		setPreferredSize(new Dimension(WIDTH,HEIGHT));		this.addMouseListener(new MouseEvents());	}		/** paint this square with graphics g */    public void paint(Graphics g) {		if ((x+y)%2 == 0)			{  g.setColor(Color.green);  }		else		    {  g.setColor(Color.red);  }    	g.fillRect(0,0,WIDTH-1,HEIGHT-1);    	         if (hasDisk) {        	g.setColor(Color.pink);        	g.fillOval(7,7,WIDTH-14,HEIGHT-14);        }     	g.setColor(Color.black);        g.drawRect(0,0,WIDTH-1,HEIGHT-1);        g.drawString("(" + x + ", " + y + ")", 10, 5+HEIGHT/2);            }        /** Complement the "has pink disk" property */    public void complementDisk()    	{  hasDisk= !hasDisk; repaint();  }        /** Remove pink disk (if present) */    public void clearDisk()     	{  hasDisk= false; repaint();  }        /** Contains methods that process mouse events */    public class MouseEvents extends MouseInputAdapter {        // Complement the "has pink disk" property        public void mouseClicked(MouseEvent e)            {  complementDisk();  }    }}