diff --git a/WatcherGui/src/main/java/com/joelhelkala/watcherGui/frames/WelcomePage.java b/WatcherGui/src/main/java/com/joelhelkala/watcherGui/frames/WelcomePage.java index 5c88b2b69f6109f55d2b1012feede5b85ac341ec..9c4476d443a9a5191966066b63c67de24040eb03 100644 --- a/WatcherGui/src/main/java/com/joelhelkala/watcherGui/frames/WelcomePage.java +++ b/WatcherGui/src/main/java/com/joelhelkala/watcherGui/frames/WelcomePage.java @@ -52,6 +52,7 @@ public class WelcomePage implements MouseListener, ActionListener { private static JFrame frame; private static JLabel chosen_label; + private static final Timer timer = new Timer(); private static NodeDataFrame nodeDataFrame = new NodeDataFrame(leftPanelWidth, topPanelHeight, width-leftPanelWidth, height-topPanelHeight-bottomPanelHeight); private static NodeSettingsFrame nodeSettingFrame = new NodeSettingsFrame(width-leftPanelWidth, height-topPanelHeight-bottomPanelHeight); @@ -202,8 +203,6 @@ public class WelcomePage implements MouseListener, ActionListener { * Polls the backend for new data every given interval */ private static void PollData() { - final Timer timer = new Timer(); - timer.scheduleAtFixedRate(new TimerTask() { int timeRemaining = pollInterval; public void run() { @@ -300,6 +299,7 @@ public class WelcomePage implements MouseListener, ActionListener { if(result == JOptionPane.YES_OPTION) { User.clear(); + timer.cancel(); frame.dispose(); LoginPage login = new LoginPage(); } @@ -389,6 +389,7 @@ public class WelcomePage implements MouseListener, ActionListener { JOptionPane.showConfirmDialog(frame, message, title, JOptionPane.ERROR_MESSAGE); User.clear(); + timer.cancel(); frame.dispose(); LoginPage login = new LoginPage(); }