title: JFrame is not refreshed after minimize on Mac OS X
body: <p>I made a java swing application, and it needs to run on Windows as well as Mac OS X.</p>
  
  <p>When the user clicks on the minimize button, the application is minimized, and an icon is created in system tray with the following code:</p>
  
  <pre><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);
  </code></pre>
  
  <p>So above code executes fine, and when the user clicks on the system tray icon, the application is restored by the code in <code>trayIcon</code> Mouse Clicked function.</p>
  
  <p>Every thing goes fine on Windows with no problems anywhere.</p>
  
  <p><strong>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.</strong></p>
  
  <p>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.</p>
  
  <p>What should I do to solve this?</p>
  
  <p>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.</p>
  
  <p><strong>It must be executed both on Windows and Mac.</strong></p>
  
  <p><img src="https://i.stack.imgur.com/njAZL.jpg" alt="enter image description here"></p>
  
  <p>Thanks</p>