From 9c2de1f2f7ef7c6630a2bf9cfe10fde1dfdeb24b Mon Sep 17 00:00:00 2001 From: kfkama Date: Thu, 17 Feb 2022 19:44:48 +0100 Subject: [PATCH 1/2] Bugfix numbers not showen --- src/main/java/Minesweeper/Cell.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/Minesweeper/Cell.java b/src/main/java/Minesweeper/Cell.java index 4991e9e..f8535eb 100644 --- a/src/main/java/Minesweeper/Cell.java +++ b/src/main/java/Minesweeper/Cell.java @@ -91,7 +91,9 @@ public class Cell extends JButton { public void reveal() { if (type == CellType.Number) { - setText(String.valueOf(value)); + if(value > 0) { + setText(String.valueOf(value)); + } } else { setBackground(MINECOLOR); } @@ -104,6 +106,7 @@ public class Cell extends JButton { setBackground(FLOODEDCOLOR); setEnabled(false); + reveal(); playfield.cellFlooded(); if (value == 0) { From 896413211c40fcb697d435dca1435d5e0709e27f Mon Sep 17 00:00:00 2001 From: kfkama Date: Thu, 17 Feb 2022 19:47:31 +0100 Subject: [PATCH 2/2] Bugfix worng colors on unflag --- src/main/java/Minesweeper/Cell.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main/java/Minesweeper/Cell.java b/src/main/java/Minesweeper/Cell.java index f8535eb..aa1a65f 100644 --- a/src/main/java/Minesweeper/Cell.java +++ b/src/main/java/Minesweeper/Cell.java @@ -18,7 +18,7 @@ public class Cell extends JButton { private static final Color FLAGCOLOR = Color.RED; private static final Color FLOODEDCOLOR = Color.LIGHT_GRAY; - private static final Color HIDDENCOLOR = Color.GRAY; + private static final Color HIDDENCOLOR = Color.WHITE; private static final Color MINECOLOR = Color.BLACK; private static final long serialVersionUID = 1L; private Playfield playfield; @@ -33,7 +33,7 @@ public class Cell extends JButton { cord = _cord; playfield = _playfield; - setBackground(Color.white); + setBackground(HIDDENCOLOR); addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -72,11 +72,9 @@ public class Cell extends JButton { if (flagged) { flagged = false; + setBackground(HIDDENCOLOR); if (type == CellType.Number) { - setBackground(HIDDENCOLOR); playfield.cellDried(); - } else { - setBackground(MINECOLOR); } } else {