Try removing them from last to first. Once you have removed 0, all the
others are shifted down, leaving 0..5. So basically by the time you go to
remove the 4th, you only have 0..3 left.
Dave Yazel
----- Original Message -----
From: Liming CHEN <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, January 31, 2001 8:14 AM
Subject: [JAVA3D] problem with removeChild()
Hi,
I add seven children (Behaviour) to a BranchGroup. Then I try to remove all
these
children by the following codes
int childNum = bg.numChildren();
for( int j =0; j<childNum; j++) {
System.out.println(" test child number" + childNum + " " + j );
bg.removeChild(j);
}
However, there is a error message as follows:
test child number7 0
test child number7 1
test child number7 2
test child number7 3
test child number7 4
Exception occurred during event dispatching:
java.lang.ArrayIndexOutOfBoundsException: 4 >= 3
at java.util.Vector.elementAt(Vector.java:417)
at javax.media.j3d.GroupRetained.doRemoveChild(GroupRetained.java:312)
at javax.media.j3d.GroupRetained.removeChild(GroupRetained.java:303)
at javax.media.j3d.Group.removeChild(Group.java:201)
at HumanBehavior.setBehaviour(HumanBehavior.java:176)
at VirtualAgent.actionPerformed(VirtualAgent.java:301)
at java.awt.MenuItem.processActionEvent(MenuItem.java:531)
at java.awt.MenuItem.processEvent(MenuItem.java:495)
the message show the index is invalid. However I think 4 is less than the
numChildren (that is 7). It should be okay. I can not figure out the reason.
Is it a bug or I make a mistake somewhere?
thanks
liming
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".