Alright I have been given an assignment to create a Memory Match Game. Now the problem i encounter is .. How can i disable the 2 image buttons after I have match them. Codes as follow.
public void handleImgBtn(ActionEvent e) {
for (int i = 0; i < gameBtn.length; i++) {
if (e.getSource() == gameBtn[i]) {
g.updateNClick();
clickTxt.setText("You have clicked " + g.getNClick() +
" time(s)");
gameBtn[i].setIcon(card[i].getImg());
if (g.getNClick() % 2 == 1) {
value1 = card[i].getImgInt();
} else if (g.getNClick() % 2 == 0) {
value2 = card[i].getImgInt();
if (value1 == value2) {
g.updateNMatching();
}
}
} //end if
} //end for
} //end handleImgBtn()
P.S: The above codes is only for the matching part only.