i am working on matching photos game, i think i may be able to reset imageIcon by know the name of conteiner lable then reset the label icon when ismatch return false in the isMatch method.
the write the following code in each label, the reset work only in the second label .. what should i do ?
public ImageIcon firstChoice;
public ImageIcon SecoundChoice;
public boolean isSelected = false;
public boolean isMatch = true;
public boolean ismatch(ImageIcon firstChoice, ImageIcon secoundChoce) {
if (firstChoice.getImage() == secoundChoce.getImage()) {
JOptionPane.showMessageDialog(null, " wowo you got it ^^");
isMatch = true;
} else {
JOptionPane.showMessageDialog(null, " notmatced");
isMatch = false;
}
return isMatch;
}
// label Mouse Clicked
private void label1MouseClicked(java.awt.event.MouseEvent evt) {
label1.setIcon(new ImageIcon("G:/Games/icons/File Server Asia.png"));
if (isSelected == true) {
ImageIcon icon1 = (ImageIcon) label1.getIcon();
firstChoice = icon1;
if (SecoundChoice != null && firstChoice != null) {
}
boolean match = ismatch(firstChoice, SecoundChoice);
if (isMatch == false) {
label1.setIcon(null);
firstChoice = SecoundChoice = null;
}
} else {
if (SecoundChoice == null) {
ImageIcon icon1 = (ImageIcon) label1.getIcon();
SecoundChoice = icon1;
isSelected = true;
}
if (isMatch == false) {
label1.setIcon(null);
}
}
}