• 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
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

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: 22815
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.
 
There is no beard big enough to make me comfortable enough with my masculinity to wear pink. Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic