Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在由JTree组成的 中DefaultMutableTreeNodes,您将如何从给定节点及其所有祖先开始遍历和删除?
JTree
DefaultMutableTreeNodes
它应该从最深的级别开始删除,向上备份到给定的节点。给定的起始节点应该是最后要删除的东西。
递归是你的朋友。
在伪代码中:
def deleteTree(root) for each child c of root deleteTree(c) end delete root end