From 4c38e09ea101f10be902023baae3af3736f6b0ec Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Thu, 22 May 2014 21:39:40 +0200 Subject: Fix timer interferences --- src/esieequest/view/app/UserInterface.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/esieequest/view/app/UserInterface.java b/src/esieequest/view/app/UserInterface.java index e0121a2..0f426bd 100644 --- a/src/esieequest/view/app/UserInterface.java +++ b/src/esieequest/view/app/UserInterface.java @@ -103,7 +103,7 @@ abstract class UserInterface implements Viewable, ActionListener { private JButton leftButton; private JButton rightButton; - private final Timer timer; + private Timer timer; private TimerTask timerTask; private boolean scenePlaying; @@ -119,7 +119,6 @@ abstract class UserInterface implements Viewable, ActionListener { this.bindKeys(); this.bindFocus(); this.setControlsState(false); - this.timer = new Timer(); this.muted = false; } @@ -625,6 +624,11 @@ abstract class UserInterface implements Viewable, ActionListener { UserInterface.this.scenePlaying = false; } }; + + if (this.timer != null) { + this.timer.cancel(); + } + this.timer = new Timer(); this.timer.schedule(this.timerTask, scene.getDuration()); } -- cgit v1.2.3