0

in a JTree comprised of DefaultMutableTreeNodes, how would you traverse and delete starting from a given Node and all it's ancestors?

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.

mKorbel
  • 109,525
  • 20
  • 134
  • 319
KJW
  • 15,035
  • 47
  • 137
  • 243

1 Answers1

2

Recursion is your friend here.

In pseudo code:

def deleteTree(root)
    for each child c of root
        deleteTree(c)
    end
    delete root
end
Ray Toal
  • 86,166
  • 18
  • 182
  • 232