void setSelectionPath(TreePath path)

解决方案 »

  1.   

    fightboy(樱桃小蚊子) 
    但是这个方法如果两个节点的名称相同就不可以的对不对?
      

  2.   

    不是 TreePath 里边本身就有一个Object[]
    包含了从root到某个节点的对象(而不是名字)的全部信息所以即使名称完全相同也没有关系的
    (就是说可以区别开)比如从TreePath的一个构造函数中可以看出来:
    public TreePath(Object[] path) Constructs a path from an array of Objects, uniquely identifying 
    the path from the root of the tree to a specific node, as returned by the tree's data model. 
    这里就说了是唯一标志了一个path的!