D
dablick
I'm trying to write some buttons that entirely expand and entirely collapse
a JTree and would appreciate any help.
For some reason, the code I have will expand the tree, but not collapse it.
Here's the basic recursive tree walking function I use to do it. Why does
it only for the expand case and not the collapse case?
void walk_subtree(TreeNode n, boolean expand) {
Enumeration e = n.children();
while (e.hasMoreElements()) {
DefaultMutableTreeNode c = (DefaultMutableTreeNode)
e.nextElement();
TreePath tp = cvt2(c);
if (expand) {
jTree1.expandPath(tp);
}
else {
jTree1.collapsePath(tp);
}
walk_subtree(c, expand);
}
}
a JTree and would appreciate any help.
For some reason, the code I have will expand the tree, but not collapse it.
Here's the basic recursive tree walking function I use to do it. Why does
it only for the expand case and not the collapse case?
void walk_subtree(TreeNode n, boolean expand) {
Enumeration e = n.children();
while (e.hasMoreElements()) {
DefaultMutableTreeNode c = (DefaultMutableTreeNode)
e.nextElement();
TreePath tp = cvt2(c);
if (expand) {
jTree1.expandPath(tp);
}
else {
jTree1.collapsePath(tp);
}
walk_subtree(c, expand);
}
}