I am new to ANTLR4, when I was first trying it out in command line I was using the grun with gui parameter. Now I am developing a Java application and I want to display the same dialog while executing my Java program.
I generated the ParseTree successfully, and I can navigate through it. But I want to display it as well. I think it has something to do with TreeViewer class but I couldn't figure out how to use it.
Thanks
解决方案
TreeViewer is a Swing Component so you should be able to add it to any other SwingComponent, e.g a JPanel.
To instantiate a TreeViewer(List rules, Tree tree) you will have to provide:
a complete list of rule names, you can use null here, but using the result of Parser.getRuleNames() produces a better result
a tree, which is the result of your parsing (something like XXXContext).