diff --git a/src/main/java/Minesweeper/TimerLable.java b/src/main/java/Minesweeper/TimerLable.java index a194bbf..ae08055 100644 --- a/src/main/java/Minesweeper/TimerLable.java +++ b/src/main/java/Minesweeper/TimerLable.java @@ -8,11 +8,12 @@ import javax.swing.JLabel; public class TimerLable extends JLabel { private static final long serialVersionUID = 1L; - private int counter = 0; + protected int counter = 0; + private Helper task; public void start() { Timer timer = new Timer(); - TimerTask task = new Helper(this); + task = new Helper(this); timer.schedule(task, 0, 1000); } @@ -20,12 +21,18 @@ public class TimerLable extends JLabel { public void update() { setText(String.valueOf(++counter)); } + + public void reset() { + task.reset = true; + } + } class Helper extends TimerTask { - public static int i = 0; + public boolean reset; + public static int i = 0; private TimerLable timerLable; public Helper(TimerLable _timerLable) { @@ -33,6 +40,10 @@ class Helper extends TimerTask } public void run() { + if(reset) { + reset = false; + timerLable.counter = 0; + } timerLable.update(); } } \ No newline at end of file