how to display a tray message when the program is just minimized to tray?

hello there

i made my program is minimized to tray when pressing the standard close button using the new features of Java SE 6 system tray

but i want to display a tray message when the program is just minimized to tray(when pressing the standard close button)

like in MSN Messenger to alarm the user that the progam is still running here,any ideas?

i tried

WindowAdapter actionListener2 =new WindowAdapter()

{

publicvoid windowClosing(WindowEvent e2){

try{

Thread.sleep(1);

trayIcon.displayMessage("Take Care !",

"JShutdown Timer Is In Progress Here.",

TrayIcon.MessageType.WARNING);

}

catch(InterruptedException un){}

}

};

isn't that right?

any one could help?

[1206 byte] By [First_knighta] at [2007-11-27 8:27:09]
# 1
even i tried windowClosed,windowIconified but not working?is there is another way to do that?any on have an idea?
First_knighta at 2007-7-12 20:16:51 > top of Java-index,Java Essentials,New To Java...
# 2
isn't there any way to do that?because i'm still searching and trying but in vain
First_knighta at 2007-7-12 20:16:51 > top of Java-index,Java Essentials,New To Java...
# 3

Try to debug your code first with simple System.out.println statements to see if your method from adapter class WindowAdapter is called at all, I don't understand you fully and I don't understand you code but you can simply add WindowListener to the thing you are closing (like JFrame) with

this.addWindowListener(new WindowAdapter(){

public void windowClosing(WindowEvent e){

//to do - when JFrame is closing!

}

});

The "this" is the reference to your Window/Frame, inside the overriden method you can invoke the operations on the system tray instance, like display message etc.

Hope this helps!

kris_javaa at 2007-7-12 20:16:51 > top of Java-index,Java Essentials,New To Java...
# 4
thanks kris_javamy error that i forgot to add the windowlistener
First_knighta at 2007-7-12 20:16:52 > top of Java-index,Java Essentials,New To Java...