Deletion of node in Tree

I have to delete all selected node in JTree. any idea.
[61 byte] By [Prashant_SDNa] at [2007-10-3 8:40:26]
# 1
Get the array "JTree#getSelectionPaths". Iterate over it and get each TreePath#getLastPathComponent.Remove the nodes with DefaultTreeModel#removeNodeFromParent.
Andre_Uhresa at 2007-7-15 3:48:37 > top of Java-index,Desktop,Core GUI APIs...
# 2

one additional query if root is also selected with child and only child should get deleted.

i am tring but facing

java.lang.IllegalArgumentException: node does not have a parent.

am i missing something?

Message was edited by:

Prashant_SDN

Message was edited by:

Prashant_SDN

Prashant_SDNa at 2007-7-15 3:48:37 > top of Java-index,Desktop,Core GUI APIs...
# 3

> ..if root is also selected with child and only child should get deleted..

For each delete-candidate node x you could check if there is a delete-candidate node y

(other than x) that has node x in its PathToRoot-array ( DefaultTreeModel#getPathToRoot(y) ).

If yes, simply set the path of x to null, so you can skip the nulls later on.

Message was edited by:

Andre_Uhres

Message was edited by:

Andre_Uhres

Andre_Uhresa at 2007-7-15 3:48:37 > top of Java-index,Desktop,Core GUI APIs...
# 4
ThnX Andre. any one has any oher suggestions.
Prashant_SDNa at 2007-7-15 3:48:37 > top of Java-index,Desktop,Core GUI APIs...