使用DefaultTreeModel
, defaultmutbletreenode
'sgetRoot()
返回它的最高祖先,但是你将如何向下一代返回它的第二高祖先?
root
- ancestor 1
- some parent
- some child
- ancestor 2
- some parent
- another parent
- some child
那么如何找到ancestor 1
,some child
在这个分支中给出,每个分支的深度对于ancestor
下的每个节点都不同root
。
我需要遍历ancestor 1
from some child
,并且还需要一个更深的分支,给定some child
,它会找到ancestor 2
.