| Author |
DefaultMutableTreeNode and setParent
|
Vladimir Bezugliy
Ranch Hand
Joined: Sep 29, 2004
Posts: 33
|
|
Why method setParent only set parent for node. But method insert() inserts child node and set parent for this child node. Why method setParent do not add node to the children?
|
 |
David Harkness
Ranch Hand
Joined: Aug 07, 2003
Posts: 1646
|
|
|
My guess: to avoid an infinate loop. insertNode() calls setParent(). If setParent() called insertNode(), chaos ensues.
|
 |
Vladimir Bezugliy
Ranch Hand
Joined: Sep 29, 2004
Posts: 33
|
|
it is possible to add child to children directly. Then there will not be a loop.
|
 |
David Harkness
Ranch Hand
Joined: Aug 07, 2003
Posts: 1646
|
|
True, but then it has to pick where to insert it (top or bottom). But that just seems like a bug waiting to happen. The bottom line seems to be that you shouldn't call setParent() yourself; problem solved.
|
 |
 |
|
|
subject: DefaultMutableTreeNode and setParent
|
|
|