Skip to content

Instantly share code, notes, and snippets.

@eduardosan
Created May 30, 2018 13:02
Show Gist options
  • Save eduardosan/6a4976bd61ea956f1409353129d65ed3 to your computer and use it in GitHub Desktop.
Save eduardosan/6a4976bd61ea956f1409353129d65ed3 to your computer and use it in GitHub Desktop.
//show AST in GUI
JFrame frame = new JFrame("Antlr AST");
JPanel panel = new JPanel();
JScrollPane scrollPane = new JScrollPane(panel);
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
scrollPane.setBounds(50, 30, 300, 50);
TreeViewer viewr = new TreeViewer(Arrays.asList(
parser.getRuleNames()),tree);
viewr.setScale(1.5);//scale a little
panel.add(viewr);
frame.add(scrollPane);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(600,400);
frame.setVisible(true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment