I made a java swing application, and it needs to run on Windows as well as Mac OS X.
When the user clicks on the minimize button, the application is minimized, and an icon is created in system tray with the following code:
MainScreen.getInstance().setExtendedState(JFrame.ICONIFIED);
trayIcon = new TrayIcon(new ImageIcon(getClass().getResource(
"/dragonstore/resources/icon.png")).getImage());
trayIcon.setToolTip("DragonStore");
trayIcon.setImageAutoSize(true);
trayIcon.addMouseListener(new MouseAdapter()
{
@Override
public void mouseClicked(MouseEvent e)
{
MainScreen.getInstance().setVisible(true);
MainScreen.getInstance().setExtendedState(NORMAL);
SystemTray.getSystemTray().remove(trayIcon);
trayIcon=null;
MainScreen.getInstance().toFront();
MainScreen.getInstance().getMainPanel().revalidate();
MainScreen.getInstance().getMainPanel().repaint();
MainScreen.getInstance().pack();
MainScreen.getInstance().validate();
MainScreen.getInstance().repaint();
System.out.println("Restore");
}
});
SystemTray.getSystemTray().add(trayIcon);
trayIcon.displayMessage("DragonStore",
"Click here to maximized window again",TrayIcon.MessageType.INFO);
setVisible(false);
So above code executes fine, and when the user clicks on the system tray icon, the application is restored by the code in trayIcon Mouse Clicked function.
Every thing goes fine on Windows with no problems anywhere.
But on Mac OS X when I restore the application, it appears with all components in animated style which is default on Mac, but once it fully restores on screen the window displays a blank window, as if the frame had no components.
I looked into the problem and found a redraw of frames bug in Mac OS X Lion, but I do not expect it is the issue here.
What should I do to solve this?
My objective is to make minimized applications be invisible from the task bar and the icon shows up in a system tray notification, so the user can restore the application by clicking on system tray icon.
It must be executed both on Windows and Mac.

Thanks
use
JFrame#setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);instead ofMainScreen.getInstance().setExtendedState(JFrame.ICONIFIED);MainScreen.getInstance().setVisible(true);should be last line (and only one code line) inpublic void mouseClicked(MouseEvent e), every code lines are useless, becauseJFrame.HIDE_ON_CLOSEonly to hideJFrame,Every thing goes fine on Windows with no problems anywhere.I doubt …, but for better help sooner post an SSCCE