|
@ -28,6 +28,7 @@ public class Cell extends JButton { |
|
|
cord = _cord; |
|
|
cord = _cord; |
|
|
playfield = _playfield; |
|
|
playfield = _playfield; |
|
|
|
|
|
|
|
|
|
|
|
setBackground(Color.white); |
|
|
addActionListener(new ActionListener() { |
|
|
addActionListener(new ActionListener() { |
|
|
@Override |
|
|
@Override |
|
|
public void actionPerformed(ActionEvent e) { |
|
|
public void actionPerformed(ActionEvent e) { |
|
@ -48,18 +49,30 @@ public class Cell extends JButton { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected void OnMouseClick() { |
|
|
protected void OnMouseClick() { |
|
|
|
|
|
if (!flagged) { |
|
|
if (type != CellType.Bomb) { |
|
|
if (type != CellType.Bomb) { |
|
|
flood(); |
|
|
flood(); |
|
|
} else { |
|
|
} else { |
|
|
playfield.reset(); |
|
|
playfield.reset(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
protected void OnMouseRightClick() { |
|
|
protected void OnMouseRightClick() { |
|
|
|
|
|
if (isEnabled()) { |
|
|
if (flagged) { |
|
|
if (flagged) { |
|
|
flagged = false; |
|
|
flagged = false; |
|
|
|
|
|
|
|
|
|
|
|
if (type == CellType.Number) { |
|
|
|
|
|
setBackground(Color.gray); |
|
|
|
|
|
} else { |
|
|
|
|
|
setBackground(Color.red); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} else { |
|
|
} else { |
|
|
flagged = true; |
|
|
flagged = true; |
|
|
|
|
|
setBackground(Color.cyan); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -75,9 +88,11 @@ public class Cell extends JButton { |
|
|
if (type == CellType.Bomb) { |
|
|
if (type == CellType.Bomb) { |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
setBackground(Color.LIGHT_GRAY); |
|
|
setBackground(Color.LIGHT_GRAY); |
|
|
setEnabled(false); |
|
|
setEnabled(false); |
|
|
playfield.cellFlooded(); |
|
|
playfield.cellFlooded(); |
|
|
|
|
|
|
|
|
if (value == 0) { |
|
|
if (value == 0) { |
|
|
if (cord.y > 0) { |
|
|
if (cord.y > 0) { |
|
|
if (playfield.cells[cord.y - 1][cord.x].type == CellType.Number |
|
|
if (playfield.cells[cord.y - 1][cord.x].type == CellType.Number |
|
|