TreePath



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.

--
Paul Tomblin <ptomblin@xxxxxxxxx> http://xcski.com/blogs/pt/
"Fly the airplane, then work the problem"
-- Rick Grant (quoting RCAF pilot training)
.



Relevant Pages

  • Re: TreePath
    ... So it seems almost an oversight to me that TreePath doesn't ... have a constructor that takes a single TreeNode, ... TreeNode implementations (DefaultMutableTreeNode, ... the output of DefaultTreeModel.getPathToRootcan be used in a TreePath constructor. ...
    (comp.lang.java.gui)
  • Re: TreePath
    ... 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 ... It has the getPath method returning an array of ...
    (comp.lang.java.gui)
  • JTree.expandPath & custom TreeNode & TreeModel
    ... JTree.expandPath doesn't work for me when I manually construct a TreePath ... I've implemented my own TreeNode and TreeModel. ... JTrees based on ...
    (comp.lang.java.gui)
  • Re: JTree.expandPath & custom TreeNode & TreeModel
    ... I've just fallen foul of something similar building my own tree path. ... If you hand a node to a treepath, the path contain that node, nothing ... TreeNode, so it can't do anything very much with it. ... the size of the array, then fill in the array on the way back down) ...
    (comp.lang.java.gui)
  • Re: Solved: Remove a Node from TreeView?
    ... Why do you expect to be able to remove a non-root node by calling Remove on ... > I've found a workaround for this bug ... > Dim TN As TreeNode = TV1.SelectedNode ... >>I've got a problem with a TreeView. ...
    (microsoft.public.dotnet.framework.compactframework)