public void movePiece(JLabel destination){
JLabel currentPiece = piece[oldIndex[0]][oldIndex[1]];
destination = currentPiece;
currentPiece.setVisible(false);
destination.repaint();
currentPiece.repaint();
}
Current method for moving. It takes the JLabel to which the text is to be “transferred”, the JLabel get’s a reference to the JLabel from which to take the text. Anyone got any idea? The method doesn’t work, just gives you an idea of how it’s going to look.
For example if this is the case:
JLabel 1: “Trololo”
JLabel 2: “Hello!”
if destination is 2 and currentPiece is 1, I’d like it to look like this:
JLabel 1: “Trololo” .setVisibility(false)
JLabel 2: “Trololo”
Effectively making only nr. 2 visible with the contents of nr. 1.
Don’t want to remove nr. 1, just keep it invisible.
(they are not referring to the same object, they just have the same text and font)
Call
setTextto change the contents of the destination: