From 40b593677ba40c2bf1ba08ad2e1b85032ae1ed9d Mon Sep 17 00:00:00 2001 From: Ray Greenwell Date: Thu, 8 Mar 2012 22:01:17 +0000 Subject: [PATCH] Let's start/stop the timer when the panel is added/removed. --- .../getdown/launcher/StatusPanel.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/threerings/getdown/launcher/StatusPanel.java b/src/main/java/com/threerings/getdown/launcher/StatusPanel.java index 31ce76f..0668e0b 100644 --- a/src/main/java/com/threerings/getdown/launcher/StatusPanel.java +++ b/src/main/java/com/threerings/getdown/launcher/StatusPanel.java @@ -63,7 +63,7 @@ public class StatusPanel extends JComponent // Add a bit of "throbbing" to the display by updating the number of dots displayed after // our status. This lets users know things are still working. - new Timer(1000, + _timer = new Timer(1000, new ActionListener() { public void actionPerformed (ActionEvent event) { if (_status != null && !_displayError) { @@ -71,7 +71,7 @@ public class StatusPanel extends JComponent updateStatusLabel(); } } - }).start(); + }); } public void init (UpdateInterface ifc, RotatingBackgrounds bg, Image barimg) @@ -153,6 +153,20 @@ public class StatusPanel extends JComponent updateStatusLabel(); } + @Override + public void addNotify () + { + super.addNotify(); + _timer.start(); + } + + @Override + public void removeNotify () + { + _timer.stop(); + super.removeNotify(); + } + // documentation inherited @Override public void paintComponent (Graphics g) @@ -353,6 +367,7 @@ public class StatusPanel extends JComponent protected Label _rlabel, _newrlab; protected UpdateInterface _ifc; + protected Timer _timer; protected long[] _remain = new long[4]; protected int _ridx;