Using a Swing Timer to hide a notification temporarily?

Javax.swing. Timer has an initial delay; just set it to 60 * 60 * 1000 Your actionPerformed() will be called an hour after invoking start().

Javax.swing. Timer has an initial delay; just set it to 60 * 60 * 1000. Your actionPerformed() will be called an hour after invoking start().

Addendum: Here's an example of a button that hide's it's enclosing window for a specified period of time. Import java.awt. EventQueue; import java.awt.

GridLayout; import java.awt.event. ActionEvent; import java.awt.event. ActionListener; import javax.swing.

JButton; import javax.swing. JFrame; import javax.swing. Timer; /** @see http://stackoverflow.com/questions/4373493 */ public class TimerFrame extends JFrame { private void display() { this.

SetTitle("TimerFrame"); this. SetLayout(new GridLayout(0, 1)); this. SetDefaultCloseOperation(JFrame.

EXIT_ON_CLOSE); this. Add(new TimerButton("Back in a second", 1000)); this. Add(new TimerButton("Back in a minute", 60 * 1000)); this.

Add(new TimerButton("Back in an hour", 60 * 60 * 1000)); this.pack(); this. SetLocationRelativeTo(null); this. SetVisible(true); } /** A button that hides it's enclosing Window for delay ms.

*/ private class TimerButton extends JButton { private final Timer timer; public TimerButton(String text, int delay) { super(text); this. AddActionListener(new StartListener()); timer = new Timer(delay, new StopListener()); } private class StartListener implements ActionListener { @Override public void actionPerformed(ActionEvent e) { TimerFrame.this. SetVisible(false); timer.start(); } } private class StopListener implements ActionListener { @Override public void actionPerformed(ActionEvent e) { timer.stop(); TimerFrame.this.

SetVisible(true); } } } public static void main(String args) { EventQueue. InvokeLater(new Runnable() { @Override public void run() { new TimerFrame().display(); } }); } }.

I edited my question, can you provide me with any example codes – SOer Dec 7 '10 at 5:25 @SOer: I added an example above. – trashgod Dec 7 '10 at 15:45 but what in case when time delay is not within 24 hrs but within one week or more than it? Should we have to count hours till that day and set it in delay?

Or is there any other way? – bsm Apr 19 '11 at 19:39 @bsm: Quartz is a popular choice, but I typicaly use at. – trashgod Apr 19 '11 at 20:00 Thanks – bsm Apr 19 '11 at 20:13.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions