From: David ‘Bombe’ Roden Date: Tue, 13 May 2008 12:40:46 +0000 (+0000) Subject: clear status bar after delay X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=bf3a49f534040fe357738d990a294c92c5bf2909;p=jSite2.git clear status bar after delay git-svn-id: http://trooper/svn/projects/jSite/trunk@860 c3eda9e8-030b-0410-8277-bc7414b0a119 --- diff --git a/src/net/pterodactylus/jsite/gui/MainWindow.java b/src/net/pterodactylus/jsite/gui/MainWindow.java index 4eb7ab7..4b447f7 100644 --- a/src/net/pterodactylus/jsite/gui/MainWindow.java +++ b/src/net/pterodactylus/jsite/gui/MainWindow.java @@ -25,6 +25,8 @@ import java.awt.Dimension; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.awt.event.WindowListener; +import java.util.Timer; +import java.util.TimerTask; import javax.swing.Action; import javax.swing.Box; @@ -50,7 +52,7 @@ import net.pterodactylus.util.swing.SwingUtils; /** * Defines the main window of the application. - * + * * @author David ‘Bombe’ Roden <bombe@freenetproject.org> * @version $Id$ */ @@ -62,6 +64,15 @@ public class MainWindow extends JFrame implements WindowListener, I18nable { /** The status bar. */ private StatusBar statusBar = new StatusBar(); + /** Timer for clearing the status bar. */ + private Timer statusBarClearTimer = new Timer("StatusBar Cleaner", true); + + /** Object for status bar clearing ticker event. */ + private TimerTask statusBarClearTimerTask; + + /** Delay (in seconds) after which to clear status bar. */ + private int statusBarClearDelay = 5000; + /** The content pane. */ private JPanel contentPane = new JPanel(new BorderLayout(12, 12)); @@ -98,7 +109,7 @@ public class MainWindow extends JFrame implements WindowListener, I18nable { /** * Creates a new main window that redirects all actions to the given swing * interface. - * + * * @param swingInterface * The swing interface to receive all actions */ @@ -119,17 +130,50 @@ public class MainWindow extends JFrame implements WindowListener, I18nable { /** * Sets the text of the status bar. - * + * * @param text * The text of the status bar */ public void setStatusBarText(String text) { statusBar.setText(text); + synchronized (statusBar) { + if (statusBarClearTimerTask != null) { + statusBarClearTimerTask.cancel(); + } + statusBarClearTimerTask = new TimerTask() { + + @Override + public void run() { + statusBar.setText("\u00a0"); + } + + }; + statusBarClearTimer.schedule(statusBarClearTimerTask, statusBarClearDelay); + } + } + + /** + * Returns the status bar clear delay (in milliseconds). + * + * @return The status bar clear delay + */ + public int getStatusBarClearDelay() { + return statusBarClearDelay; + } + + /** + * Sets the status bar clear delay (in milliseconds). + * + * @param statusBarClearDelay + * The status bar clear delay + */ + public void setStatusBarClearDelay(int statusBarClearDelay) { + this.statusBarClearDelay = statusBarClearDelay; } /** * Sets whether the advanced mode is activated. - * + * * @param advancedMode * true if the advanced mode is activated, * false if the simple mode is activated @@ -151,7 +195,7 @@ public class MainWindow extends JFrame implements WindowListener, I18nable { /** * Returns the currently selected project. - * + * * @return The currently selected project */ public Project getSelectedProject() { @@ -333,7 +377,7 @@ public class MainWindow extends JFrame implements WindowListener, I18nable { // // INTERFACE WindowListener // - + /** * {@inheritDoc} */