This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes how to minimize a window to system tray , and how to restore it from trayIcon's popup menu....??? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "how to minimize a window to system tray , and how to restore it from trayIcon Watch "how to minimize a window to system tray , and how to restore it from trayIcon New topic
Author

how to minimize a window to system tray , and how to restore it from trayIcon's popup menu....???

Sanjeev Charla
Ranch Hand

Joined: Apr 02, 2009
Posts: 90

in a swing application, we add a sysem tray icon to the application... but, how can we minimize the window to notificaiton area instead of normal window minimize operation... we added a pop up menu to tray icon... by handling mouse events we can quit the application by using exit(0) function... but how can we restore a minimized window... please explain... thank you...
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

Minimizing to tray is quite easy, when you use a WindowListener:
This will really hide the window right after it has been minimized (called iconified in Java).

Restoring is not that different:
The first line retrieves the current state, which is a bitmask. It then sets the ICONIFIED (minimized) part to false, then sets the same state again. This way, if the program was maximized before it will be maximimized again, etc. Of course a setVisible(true) must follow to show the window again.


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
Sanjeev Charla
Ranch Hand

Joined: Apr 02, 2009
Posts: 90

thank you sir..
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: how to minimize a window to system tray , and how to restore it from trayIcon's popup menu....???
 
Similar Threads
Define a global hotkey in SWT/RCP
When click on minimize button then it must goes to System Tray?
questions regarding system tray and tray icon
Getting Info about Opened Windows In Xp
run jsdk2.1 webserver minimised.[as soon as possible]