title: JFrame stops displaying when it previously displayed before
body: <p>This is a follow on question from <a href="https://stackoverflow.com/questions/6145405/display-and-interact-with-an-html-form-in-a-swing-application">Display and interact with an HTML form in a Swing application</a>. I've copied the code and run it successfully while in Eclipse (Indigo) but for some mysterious reason it's stopped working. I was able to run it several times in a row, but now I'm lucky if I can get it to work at all.</p>
  
  <p>Running it with JUnit under debug, it I've single stepped up to the<code>javax.swing.SwingUtilities.invokeLater(new Runnable() {</code> line;  The next step jumps straight to the <code>System.in.read()</code> line effectively skipping the display logic.</p>
  
  <p>I suspect its got something to the <code>invokeLater</code> method.  From my research, <code>invokeLater</code> puts its <code>Runnable()</code> on the dispatch queue and the <code>Runnable</code> will be run whenever the VM gets around to it.  There's some mention that if a <code>Runnable()</code> experiences and exception it won't "unwind", which I assume means that it won't close and will end up blocking the queue. I suspect that one of my invocations has stopped and is clogging the queue but have no idea why or how to clear the queue.</p>
  
  <p>Questions:
  Is there any way to clear the queue?  I've stopped and restarted Eclipse several times thinking that would clear the dispatch queue, but no luck.</p>
  
  <p>Is it possible that as far as Java is concerned the <code>JFrame</code> <strong>is</strong> displaying, but it's not actually showing up on the screen so I can hit the submit button?  What would cause this?  Why would it work several times in a row, then suddenly stop?</p>
  
  <p>Below is the relavant code.</p>
  
  <p>JUnit stub:</p>
  
  <pre><code>@Test
  public final void testTestForms()  {
      // https://stackoverflow.com/questions/6145405/display-and-interact-with-an-html-form-in-a-swing-application
      Navigate n = new Navigate();
      try {
          n.testForms();
          n= null;  // in desperate attempt to garbage collect
      } catch (IOException e) {
          System.out.println("Error invoking n.testForms()");
          e.printStackTrace();
          n= null;
      }
      n = null;
  
  }
  </code></pre>
  
  <p>The subject under study:</p>
  
  <pre><code>public class Navigate  {
  @Test
  public void testForms() throws IOException {
      System.out.println("in testForms()");
      javax.swing.SwingUtilities.invokeLater(new Runnable() {
          public void run() {
              System.out.println("in run()");
              javax.swing.JFrame jf = new javax.swing.JFrame();
              jf.setSize(300, 300);
              jf.setVisible(true);
              jf.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
  
              JTextPane textPane = new JTextPane();
              textPane.setContentType("text/html");
              textPane.setEditable(false);
              textPane.setText("&lt;html&gt;" + "&lt;body&gt;" + "&lt;form action=\"#\"&gt;"
                      + "&lt;input name=\"input1\" type=\"text\" /&gt;"
                      + "&lt;input name=\"input2\" type=\"text\" /&gt;&lt;br/&gt;"
                      + "&lt;input name=\"cb1\" type=\"checkbox\" /&gt;&lt;br/&gt;"
                      + "&lt;input name=\"rb1\" type=\"radio\" /&gt;&lt;br/&gt;"
                      + "&lt;input type=\"submit\" value=\"go\" /&gt;" + "&lt;/form&gt;"
                      + "&lt;/body&gt;" + "&lt;/html&gt;");
  
              jf.getContentPane().setLayout(
                      new BoxLayout(jf.getContentPane(), BoxLayout.Y_AXIS));
  
              jf.getContentPane().add(textPane);
  
              HTMLEditorKit kit = (HTMLEditorKit) textPane.getEditorKit();
              kit.setAutoFormSubmission(false);
              textPane.addHyperlinkListener(new HyperlinkListener() {
                  public void hyperlinkUpdate(HyperlinkEvent e) {
                      if (e instanceof FormSubmitEvent) {
                          System.out.println(((FormSubmitEvent) e).getData());
                      }
                  }
              });
          }
      }
  );
      // try to catch exceptions that could plug the queue?
      try {
          System.in.read();
      } catch (IOException e) {
      System.out.println("Error with System.in.read()");
          e.printStackTrace();
          throw new IOException(e);
      }
      try {
          finalize();  // another desperate attempt
      } catch (Throwable e) {
          e.printStackTrace();
      }
  }
  }
  </code></pre>