title: How to output ANTLR grammar build to screen (e.g. to JOptionPane like ANTLRworks CTRL-r)
body: <p>I can load a grammar file in to my java project (in netbeans) and generate/build my lexer and parser classes, load them via reflection and then parse what I need to parse.</p>
  
  <p>What I would like is a simple example of redirecting the results from the generate/build of the lexer and parser to a string so that I can put the errors to a popup like JOptionPane.
  Just like ANTLRworks does when you do CTRL-R (in windows at least) showing Error(123) grammar.g:100:12: ...Warning...etc...</p>
  
  <p>Now I am already using a DiagnosticCollector but this does not always enough details as the CTRL-r in ANTLRworks does. The idea being the user corrects the grammar in order to correct the mistake.</p>
  
  <p>Here's a snippet of my code</p>
  
  <pre><code>            Tool tool = new Tool(new String[]{userDir + grammarPath + grammarName + ".g"});
              //tool.setOutputDirectory(userDir + grammarPath );
              tool.process();
              if(tool.getNumErrors()&gt;0) {
                  errors=true;
                  unableToLoadGrammar_AddLine("1. Detected "+tool.getNumErrors()+" Error(s)"+tool.toString()+"\n");
              }
  </code></pre>
  
  <p>Thanks</p>