This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
hello everybody ,
I'm worth SystemTray created a how to do when I click miminse the frame reduce next ticon SystemTray and when I click 2 times on the icon SystemTray next to the window displayed the frame.
thank you in advance.
Minimizing to system tray is little more than first minimizing, then hiding the frame using setVisible(false). You can use a WindowListener to listen to minimize events (called iconify in Java), and use setExtendedState to minimize the frame from code.
Restoring on double clicking isn't that hard either. Add an ActionListener or MouseListener to the TrayIcon. If you use a MouseListener you can use MouseEvent.getClickCount() to notice if it's a double click or not.
You'll need to restore the frame from code. The process is again simple: first call setVisible(true), then use setExtendedState to remove the iconified state:
By using the current state and "removing" the iconified part your frame will get its previous state - maximized, normal, or whatever it had before.