[antlr-interest] Re: ANTLR 3 tree structure stuff

atripp54321 atripp at comcast.net
Wed Nov 10 07:12:14 PST 2004



Terrance,

Why not use the built-in Swing TreeNode data structure?
TreeNode is the interface: 
http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/tree/TreeNode.html
and DefaultMutableTreeNode is your typical implementation:
http://java.sun.com/j2se/1.5.0/docs/api/javax/swin
g/tree/DefaultMutableTreeNode.html

DefaultMutableTreeNode (ugg, what an awful name!) may seem like
overkill, but hey, if the code's already there and working, why not?
If you want something simpler, just subclass MutableTreeNode
instead.

The only difference I see between your proposal and this is
that you have stuff like getNextSibling(), while the built-in
one forces you to use an iterator (actually, it's still using
Enumeration rather than Iterator - another uggh!).

I always thought it strange that Sun chose to put their
List and Map data structures in the java.util package, but their
Tree data structure in javax.swing. Oh well...nonetheless, it
is a true, full-featured and flexible Tree data structure.

See also the tutorial:
http://java.sun.com/docs/books/tutorial/uiswing/components/tree.html
Note that creating a visual JTree becomes trivial, just pass it
the root DefaultMutableTreeNode:
JTree tree = new JTree(root);

Andy





 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 





More information about the antlr-interest mailing list