};
}
/** Display this object (and so objects) as a tree; if listener!=null, it will receive OurTree.Event.SELECT events. */
public final JFrame showAsTree(Listener listener) {
final OurTree tree = new OurTree(12) {
private static final long serialVersionUID = 0;
private final boolean onWindows = Util.onWindows();
{do_start();}
@Override public String convertValueToText(Object val,boolean selected,boolean expanded,boolean leaf,int row,boolean focus) {
String c = ">";
String x = (val instanceof Browsable) ? ((Browsable)val).getDescription() : String.valueOf(val);
if (onWindows) c = selected ? " style=\"color:#ffffff;\">" : " style=\"color:#000000;\">";
return "<html> <span" + c + x + "</span></html>";
}
@Override public List<?> do_ask(Object parent) {
if (parent instanceof Browsable) return ((Browsable)parent).getSubnodes(); else return new ArrayList<Browsable>();
}
@Override public Object do_root() { return Browsable.this; }
};
tree.setBorder(new EmptyBorder(3,3,3,3));
final JScrollPane scr = new JScrollPane(tree, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scr.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) { tree.requestFocusInWindow(); }
public void focusLost(FocusEvent e) { }
});
final JFrame x = new JFrame("Parse Tree");
x.setLayout(new BorderLayout());
x.add(scr, BorderLayout.CENTER);