I'm pretty new in programming, but i need to program the game Minesweeper. basically the game is running, but there are some parts that wont work at all.
The first problem are the flags. My Minesweeper is able to set flag by right clicking on a field, but everytime i do a left-click on a field with a flag, the field will override the flag.
Field after a right click
Flagged field after a left click
Is there any way to set the flag "absolute" or final or something?
Here is the code:
@Override
public void mouseClicked(MouseEvent arg0) {
if (SwingUtilities.isRightMouseButton(arg0)) {
setFlag();
} else if (SwingUtilities.isLeftMouseButton(arg0)) {
checkMine();
}
public void setFlag() {
button.setEnabled(false);
button.setText(flag);
button.setBackground(Color.LIGHT_GRAY);
}
public void checkMine() {
button.setEnabled(false);
display();
check = false;
if (value == 0)
log.emptyCells();
if (value == -1)
log.fail();
if (value == -3)
log.lucky();
}
I hope that someone here can help me.
tanks :)