Re: TreePath
- From: "Steve W. Jackson" <stevewjackson@xxxxxxxxxxx>
- Date: Tue, 26 Sep 2006 11:24:20 -0500
In article <efb9vu$271$1@xxxxxxxxxxxxxxxxx>,
ptomblin+netnews@xxxxxxxxx (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, or that any of the known
TreeNode implementations (DefaultMutableTreeNode,
JTree.DynamicUtilTreeNode) includes a method to get a TreePath for that
node.
Oh well, I guess I'll write my own TreeNode implementation that does it.
<http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/tree/DefaultMutableT
reeNode.html>
Take another look. It has the getPath method returning an array of
TreeNode, which represents the path from the root node. Since TreePath
has a constructor accepting an array of Object representing exactly that
-- the path from the root to a designated node -- I don't see what's
missing.
--
Steve W. Jackson
Montgomery, Alabama
.
- References:
- TreePath
- From: Paul Tomblin
- TreePath
- Prev by Date: Re: ComboBox width before setVisible??
- Next by Date: focusLost vs. actionPerformed
- Previous by thread: Re: TreePath
- Next by thread: Re: TreePath
- Index(es):
Relevant Pages
|
|