File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Automatically closing windows after time Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Automatically closing windows after time" Watch "Automatically closing windows after time" New topic
Author

Automatically closing windows after time

Jo Cook
Greenhorn

Joined: Mar 20, 2002
Posts: 2
Hi
I just recently passed my Java Prog Cert but still consider myself a beginner since most of my work has been theoretical until now...
I am trying to build a small standalone app that pops up a frame every 30 minutes with a reminder. I have built a simple app to do that using java.util.Timer, but my problem is that I would automatically like the window to close after 1 minute if the user doesn't close it. For example if I am away from my pc for a few hours I don't want to come back and find lots of reminder windows on top of each other.
Any ideas?
Maybe I should have a single frame that automatically minimises and maximises itself instead?
Jo
Rob Ross
Bartender

Joined: Jan 07, 2002
Posts: 2205
You can use a Timer for that as well. Start a timer when the window is set to visible. You can re-set the timer as needed whenever some activity occurs in the the window, perhaps by overriding repaint() to start a new Timer, then call the superclass version.
If the timer counts down to zero, have it invoke a method in your Frame that closes it, ie, calls dispose(), or setVisible(false), etc.


Rob
SCJP 1.4
Jo Cook
Greenhorn

Joined: Mar 20, 2002
Posts: 2
duh! of course it's dispose...
Thanks Rob - can't see the wood for the trees

Jo
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Automatically closing windows after time