日期:2014-05-20  浏览次数:20710 次

急!jtree 遍历
我想得到指定节点的所有子节点treepath(路径),不是只要节点名称,我该怎么做呢?

------解决方案--------------------
Java code

DefaultMtableTreeNode node = 指定的节点;

int chlCount = node.getChildCount();
List<TreePath[]> paths = new ArrayList<TreePath[]>();

DefaultMtableTreeNode chlNode = null;
for(int i = 0; i < chlCount; i++){
  chlNode = node.getChildAt(i);
  paths.add(chl.getPath());
}