Re: TreePath
- From: Thomas Weidenfeller <nobody@xxxxxxxxxxxxxxxx>
- Date: Tue, 26 Sep 2006 18:14:15 +0200
Paul Tomblin wrote:
It seems to me that if your tree contains TreeNodes, it should be trivial
to construct a TreePath for a TreeNode by just calling ".getParent()" on
each node in turn until you reach the root, pushing each node onto the top
of a stack. So it seems almost an oversight to me that TreePath doesn't
have a constructor that takes a single TreeNode,
Yes, the JTree-related classes are missing a few things.
or that any of the known
TreeNode implementations (DefaultMutableTreeNode,
JTree.DynamicUtilTreeNode) includes a method to get a TreePath for that
node.
Well, it is not a TreeNode which is supposed to know a path. However, the output of DefaultTreeModel.getPathToRoot(TreeNode tn) can be used in a TreePath constructor. But that is via the model, not directly from a node, and only if you use (a subclass of) DefaultTreeModel.
/Thomas
--
The comp.lang.java.gui FAQ:
http://gd.tuwien.ac.at/faqs/faqs-hierarchy/comp/comp.lang.java.gui/
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
.
- References:
- TreePath
- From: Paul Tomblin
- TreePath
- Prev by Date: TreePath
- Next by Date: Re: ComboBox width before setVisible??
- Previous by thread: TreePath
- Next by thread: Re: TreePath
- Index(es):
Relevant Pages
|