@Override
	public void mouseClicked(MouseEvent e) 
	{
		// If this is the first time a position is selected
		//  and there is a legitimate piece, then mark it
		if (from == null)
		{
			ChessPosition pos = getChessPositionFromClick(e);
			ChessPiece p = pieceAt(pos);
			if (p == null)
				return;
			setPieceToMove(p);
		}
		else
		{
			try
			{
				ChessPiece moving_piece = pieceAt(from);
				if (moving_piece == null)
				{
					from = null;
					return;
				}
				
				ChessPosition pos = getChessPositionFromClick(e);
				if (pos == null)
				{
					from = null;
					return;
				}
				
				// If there is a piece at the target position
				//  and if that piece is the same color, then
				//  the player has changed the mind about the 
				//  piece they want to move, so reset the piece
				ChessPiece p = this.pieceAt(pos);
				if ((p != null) && (p.getColor() == moving_piece.getColor()))
				{
					setPieceToMove(p);
					return;
				}
				
				makeMove(from, pos);
				// Remove all the border highlights
				this.removeMoveHighlights();
				
				// reset where you came from
				from = null;
				// Switch the sides to make the move
				turn = (turn == ChessColor.COLOR_BLACK)?ChessColor.COLOR_WHITE:ChessColor.COLOR_BLACK;					
			}
			catch (ChessException ce)
			{
				from = null;
			}
		}
	}