I do like this:
// scene---- BranchGroup , is live
// objScale— TransformGroup, is live
u.getLocale().removeBranchGraph(scene);
objScale.removeChild(objScale.numChildren()-1);
objScale.addChild(g);
u.getLocale().addBranchGraph(scene);
I call this code when I move the mouse. At first it is ok , but after sereval times , there is error:
Exception occurred during Behavior initialization:
java.lang.NullPointerException
at javax.media.j3d.WakeupCriterion.cleanTree(WakeupCriterion.java:74)
at javax.media.j3d.WakeupOr.cleanTree(WakeupOr.java:73)
at javax.media.j3d.BehaviorRetained.wakeupOn(BehaviorRetained.java:312)
at javax.media.j3d.Behavior.wakeupOn(Behavior.java:221)
at com.sun.j3d.utils.behaviors.mouse.MouseBehavior.initialize(MouseBehavior.java:201)
at com.sun.j3d.utils.behaviors.mouse.MouseRotate.initialize(MouseRotate.java:137)
at javax.media.j3d.BehaviorRetained.executeInitialize(BehaviorRetained.java:290)
at javax.media.j3d.Locale.doAddBranchGraph(Locale.java:204)
at javax.media.j3d.Locale.addBranchGraph(Locale.java:163)
at best.Applet1.drawlineD(Applet1.java:8880)
at best.Applet1.lineMoved(Applet1.java:3619)
Please tell me whether my method of adding a TransformGroup to another live TransformGroup is right. Or how to add a TransformGroup into another live ? Thanks!