• 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:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Running java in the background

 
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi guys,

I have developed a java application(an alarm which can be customised by the user). I want the application to run in the background(like utorrent). If the user pressed the exit button the application must not close down rather it must go to the system tray.

How can this be achieved .

Please help me
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is this a Swing application?

Check out http://java.sun.com/developer/technicalArticles/J2SE/Desktop/javase6/systemtray/
 
Sheriff
Posts: 22817
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Minimizing to the system tray is done by adding an icon to the system tray, then calling setVisible(false) on your frame to hide it from the task bar. You may want to keep normal minimizing in there for the effect. The procedure is then like this (using a WindowListener):
To show it again, turn off the minimized (iconified) state and show it again:
To minimize in the closing event (which is called when you press the X) as well use the reverse for minimizing:
Keep in mind that this will cause another windowIconified event, so if you minimize in the closing event remove the hiding and the tray icon code from that event. The other event will handle that.


Moving to our Swing forum.
 
PrasannaKumar Sathiyanantham
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Maneesh and Rob Prime. I will implement it today and get back to you guys.
 
Why does your bag say "bombs"? The reason I ask is that my bag says "tiny ads" and it has stuff like this:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic