Forums Register Login

questions regarding system tray and tray icon

+Pie Number of slices to send: Send
hi there. i am developing a chat app... i wanted to add the feature of the messengers like YM that if it closes, it goes to the system tray...
i got this piece of code...



its from a post of mr. Rob Prime... i slightly understand what this is for. all i want to know is how to put the frame on the tray... :O
hope you guys help.
+Pie Number of slices to send: Send
More on using the system tray here
http://java.sun.com/docs/books/tutorial/uiswing/misc/systemtray.html

I have reason to believe Mr. Rob Prime will be around today.
+Pie Number of slices to send: Send
 

Maneesh Godbole wrote:More on using the system tray here
http://java.sun.com/docs/books/tutorial/uiswing/misc/systemtray.html

I have reason to believe Mr. Rob Prime will be around today.



thanks Mr. Maneesh. i got myself on these codes...



i can see the icon on the system tray already. i set the setDefaultCloseOperation to DO_NOTHING_ON_CLOSE. but everytime i hit the [X] on the title bar, my app would still close and terminate.
did i do something wrong on the code?
+Pie Number of slices to send: Send
if you are using Java 1.6 you can use SystemTray class and put a TrayIcon class in it.
like this:


On your JFrame, add a Class of type WindowAdapter and provide appropriate actions when user closes the Application window(usually you will want to hide the JFrame)

sample window adapter


Then on the JFrame you may do something like this.


Hope this sample helps!
Ryan Webb
+Pie Number of slices to send: Send
 

Maneesh Godbole wrote:I have reason to believe Mr. Rob Prime will be around today.


I guess you're right

Ryan is showing you the right way to minimize to tray. The minimization occurs all by itself but unless you hide the frame as well it will still be visible in the task bar. The reverse is first showing the frame again, then removing the minimized state as you already know how to.

Jhedzkie, are you sure your application is really terminating? Does the tray icon disappear as well? Is the java.exe or javaw.exe still visible in the Windows Task Manager?
I've tried your test code for the JFrame only (so not the tray icon), and if I click [X] it minimizes and restores immediately after. Are you sure the frame has no other window listeners attached to it? If another window listener causes the application to be closed then that one is executed first.
+Pie Number of slices to send: Send
 

Rob Prime wrote:

Maneesh Godbole wrote:I have reason to believe Mr. Rob Prime will be around today.


I guess you're right

Ryan is showing you the right way to minimize to tray. The minimization occurs all by itself but unless you hide the frame as well it will still be visible in the task bar. The reverse is first showing the frame again, then removing the minimized state as you already know how to.

Jhedzkie, are you sure your application is really terminating? Does the tray icon disappear as well? Is the java.exe or javaw.exe still visible in the Windows Task Manager?
I've tried your test code for the JFrame only (so not the tray icon), and if I click [X] it minimizes and restores immediately after. Are you sure the frame has no other window listeners attached to it? If another window listener causes the application to be closed then that one is executed first.



yes it is. O_O
that is the only window listener that is present on the frame.
i am using net beans 6.7..

the output pane below says,

BUILD SUCCESSFUL (total time: 4 second)


right after i clicked the [X] button. the system tray icon is showing flawlessly. the only problem is that it closes when i hit [X]
Not looking good. I think this might be the end. Wait! Is that a tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 4913 times.
Similar Threads
save search criteria when deiconified.....
When click on minimize button then it must goes to System Tray?
Running java in the background
my frame starts up minimized...
reduce display frame SystemTray
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 18, 2024 22:43:47.