From d6f1baffe9cc878be102568f9f0f9e038cafc0b1 Mon Sep 17 00:00:00 2001 From: kfkama Date: Thu, 17 Feb 2022 20:18:46 +0100 Subject: [PATCH] Timer stops while game end dialog is open --- src/main/java/Minesweeper/Playfield.java | 1 + src/main/java/Minesweeper/TimerLable.java | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/src/main/java/Minesweeper/Playfield.java b/src/main/java/Minesweeper/Playfield.java index 425f4f2..29dde34 100644 --- a/src/main/java/Minesweeper/Playfield.java +++ b/src/main/java/Minesweeper/Playfield.java @@ -141,6 +141,7 @@ public class Playfield { } } } + MsG.tl.stop(); MsG.repaint(); } diff --git a/src/main/java/Minesweeper/TimerLable.java b/src/main/java/Minesweeper/TimerLable.java index ae08055..750e417 100644 --- a/src/main/java/Minesweeper/TimerLable.java +++ b/src/main/java/Minesweeper/TimerLable.java @@ -24,14 +24,19 @@ public class TimerLable extends JLabel { public void reset() { task.reset = true; + task.stop = false; } + public void stop() { + task.stop = true; + } } class Helper extends TimerTask { public boolean reset; + public boolean stop; public static int i = 0; private TimerLable timerLable; @@ -40,6 +45,9 @@ class Helper extends TimerTask } public void run() { + if(stop) { + return; + } if(reset) { reset = false; timerLable.counter = 0;