title: JWindow not repainting until JFrame returns from while loop
body: <p>Assume I have a JWindow and a JFrame called TestWindow and TestFrame which should both be shown at the same time, why does the TestWindow only draw a blank grey window without its label while the TestFrame is inside the while(true)???</p>
  
  <p>And why if I remove the while(true) the TestWindow correctly shows?</p>
  
  <p>This is as example of a more complex program where I need to show a splashscreen while the main application is starting which takes 1 or 2 seconds.
  During this time the splashscreen should be shown regardless of the state of the main application, instead the splashscreen shows only when the main application is already finished, invokeAndWait doesn't actually wait for the splashscreen to be initialized.</p>
  
  <p><strong>TestFrame.java</strong>:</p>
  
  <pre><code>import java.awt.BorderLayout;
  import javax.swing.JFrame;
  import javax.swing.JLabel;
  import javax.swing.SwingUtilities;
  
  public class TestFrame extends JFrame
  {
      public static void main(String args[])
      {
          try
          {
             SwingUtilities.invokeAndWait(new Runnable()
             {
                 @Override
                 public void run()
                 {
                     new TestWindow();
                 }
             });
          }
          catch (Exception ex)
         {
             Logger.getLogger(TestFrame.class.getName()).log(Level.SEVERE, null, ex);
         }
         SwingUtilities.invokeLater(new Runnable()
         {
             @Override
             public void run()
             {
                 new TestFrame();
             }
          });
      }
  
      public TestFrame()
      {
          super("TestFrame");
          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          getContentPane().add(new JLabel("sss"), BorderLayout.CENTER);
          setSize(500, 120);
          setVisible(true);
          while(true)
          {
              //this makes the other not show
          }
      }
  }
  </code></pre>
  
  <p><strong>TestWindow.java</strong>:</p>
  
  <pre><code>import java.awt.BorderLayout;
  import javax.swing.JLabel;
  import javax.swing.JPanel;
  import javax.swing.JWindow;
  
  public class TestWindow
  {
      public TestWindow()
      {
          JWindow jWindow = new JWindow();
          JPanel contentPanel = new JPanel();
          final JLabel label = new JLabel("Test Window");
          contentPanel.add(label, BorderLayout.CENTER);
          jWindow.add(contentPanel);
          jWindow.setSize(300, 200);
          jWindow.setAlwaysOnTop(true);
          jWindow.setVisible(true);
      }
  }
  </code></pre>
  
  <p><strong>EDIT</strong>:</p>
  
  <p>By the way, I realized putting a </p>
  
  <pre><code>catch (Exception ex)
          {
              Logger.getLogger(TestFrame.class.getName()).log(Level.SEVERE, null, ex);
          }
          try
          {
              Thread.sleep(1000);
          }
  </code></pre>
  
  <p>between the two TestWindow and TestFrame creation actually solves the problem, isn't there anything less hacky than this???</p>