I'm trying to move a piece from one square in a grid to another by clicking first on the piece and then clicking on the square to move it too.
How can I save the location of the first icon, and then swap it with the second?
At the moment I'm looking at this code which simply moves the piece one square left:
public void actionPerformed(ActionEvent e)
{
for ( x=0; x<8; x++)
for( y=0; y<8; y++) {
if(e.getSource() == board[x][y])
((ChessSquare)e.getSource()).swap(board[x][y-1]);
}
}