[英]how to recursively delete all nodes in JTree?
in a JTree
comprised of DefaultMutableTreeNodes
, how would you traverse and delete starting from a given Node and all it's ancestors? 在由
DefaultMutableTreeNodes
组成的JTree
中,您将如何从给定节点及其所有祖先开始遍历和删除?
it should delete starting at it's deepest level , backing upwards to the given Node. 它应该从最深层次开始删除,向上备份到给定节点。 the given starting node should be the last thing to remove.
给定的起始节点应该是最后删除的东西。
Recursion is your friend here. 递归是你的朋友。
In pseudo code: 在伪代码中:
def deleteTree(root)
for each child c of root
deleteTree(c)
end
delete root
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.