title: Antlr 4 JDialog created by tree.inspect(parser) is automatically closed by JUnit
body: <p>In Antlr 4, such code works in a general main function.</p>
  
  <pre><code>public static void main(String[] args) {
     .....
     SicstusPrologParser parser = new SicstusPrologParser(tokens);
     ParserRuleContext tree =(ParserRuleContext)parser.program();
     tree.inspect(parser);
  }
  </code></pre>
  
  <p>The last statement pops up a model JDialog which shows the parser tree structure. But I copied the code into a junit test case as below:</p>
  
  <pre><code> @Test
  public void testParserClause() { //clause
      .....
     SicstusPrologParser parser = new SicstusPrologParser(tokens);
     ParserRuleContext tree =(ParserRuleContext)parser.program();
     tree.inspect(parser);
   }
  </code></pre>
  
  <p>The JDialog created by "tree.inpect(parser)"  has just been closed by junt before I clicked the "OK" button. I dived into the "inspect" function, its main logic flow is as the following:</p>
  
  <pre><code>   .....
   Callable&lt;JDialog&gt; callable = new Callable&lt;JDialog&gt;() {
      JDialog result;
  
      @Override
          public JDialog call() throws Exception {
              SwingUtilities.invokeAndWait(new Runnable() {
                  @Override
                  public void run() {
                                           //fill the tree nodes and show the dialog.
                      result = showInDialog(viewer);
                  }
              });
  
              return result;
          }
      };
  
      ExecutorService executor = Executors.newSingleThreadExecutor();
  
      try {
          return executor.submit(callable);
      }
      finally {
          executor.shutdown();
      }
  </code></pre>
  
  <p>Why is the model JDialog closed before I do sth with it? I used the return value of "inspect", but it still did work.</p>
  
  <pre><code>       Future&lt;JDialog&gt; fu = tree.inpect(parser);
         fu.get();
  </code></pre>
  
  <p>any help?</p>