public void movePiece(JLabel destination){
JLabel currentPiece = piece[oldIndex[0]][oldIndex[1]];
destination = currentPiece;
currentPiece.setVisible(false);
destination.repaint();
currentPiece.repaint();
}
当前的移动方法。它采用要“传输”文本的 JLabel,JLabel get 是对从中获取文本的 JLabel 的引用。有人知道吗?该方法不起作用,只是让您了解它的外观。
例如,如果是这种情况:
JLabel 1:“Trololo” JLabel 2:“你好!”
如果目标是 2 并且 currentPiece 是 1,我希望它看起来像这样:
JLabel 1:“Trololo” .setVisibility(false) JLabel 2:“Trololo”
有效地只制作 nr。2 可见与 nr 的内容。1.不想删除nr。1,只是保持它不可见。
(它们不是指同一个对象,它们只是具有相同的文本和字体)