• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Automatically closing windows after time

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Jo Cook
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
duh! of course it's dispose...
Thanks Rob - can't see the wood for the trees

Jo
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic