0
public void movePiece(JLabel destination){
JLabel currentPiece = piece[oldIndex[0]][oldIndex[1]];
destination = currentPiece;
currentPiece.setVisible(false);
destination.repaint();
currentPiece.repaint();
}
當前的移動方法。它需要JLabel將文本「傳送」到,JLabel得到對JLabel的引用,從中可以讀取文本。任何人有任何想法?該方法不起作用,只是讓你知道它將如何看待。如何將一個JLabel的內容傳輸給另一個?
例如,如果是這樣的話:
的JLabel 1: 「Trololo」 的JLabel 2: 「你好!」
如果目的地是2和currentPiece是1,我想它是這樣的:
的JLabel 1: 「Trololo」 .setVisibility(假) 的JLabel 2: 「Trololo」
有效只做nr。 2可見與nr的內容。 1. 不想刪除編號。 1,只是讓它看不見。
(他們是不是指同一個對象,他們只是有相同的文字和字體)
謝謝,不知道有是那個getters! – 2011-01-14 08:57:11