• Post Reply Bookmark Topic Watch Topic
  • New Topic

Running java in the background

 
PrasannaKumar Sathiyanantham
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • 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
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
 
Rob Spoor
Sheriff
Posts: 20822
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thank you Maneesh and Rob Prime. I will implement it today and get back to you guys.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!