That's kind of a joke!!!
are you aware that removing children could cause the numChildren() to decrement????
This was refreshing!
Cheers,
Karsten
Liming CHEN wrote:
> 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".