01: package persistence.antlr.debug.misc;
02:
03: /* ANTLR Translator Generator
04: * Project led by Terence Parr at http://www.jGuru.com
05: * Software rights: http://www.antlr.org/license.html
06: *
07: */
08:
09: import java.awt.*;
10: import javax.swing.*;
11: import javax.swing.tree.*;
12: import javax.swing.event.*;
13:
14: public class JTreeASTPanel extends JPanel {
15: JTree tree;
16:
17: public JTreeASTPanel(TreeModel tm, TreeSelectionListener listener) {
18: // use a layout that will stretch tree to panel size
19: setLayout(new BorderLayout());
20:
21: // Create tree
22: tree = new JTree(tm);
23:
24: // Change line style
25: tree.putClientProperty("JTree.lineStyle", "Angled");
26:
27: // Add TreeSelectionListener
28: if (listener != null)
29: tree.addTreeSelectionListener(listener);
30:
31: // Put tree in a scrollable pane's viewport
32: JScrollPane sp = new JScrollPane();
33: sp.getViewport().add(tree);
34:
35: add(sp, BorderLayout.CENTER);
36: }
37: }
|