How do I display ASTs graphically

Instead of using t.toStringTree(), you can ask ANTLR to generate DOT/graphviz format:

DOTTreeGenerator gen = new DOTTreeGenerator();
StringTemplate st = gen.toDOT(t);

To display in a Swing window (Java target), use this:

CommonTree t = (CommonTree) r.getTree();
ASTFrame af = new ASTFrame("Tree", t);

where you need the attached code from Jörg Werner.