Dear friends,

I want to remove one child from TransformGroup(TG) by
pressing one button, codes like this:

[/CODES]
class AWTInteractionBehavior extends Behavior
implements ActionListener {

    private TransformGroup transformGroup;
    private BranchGroup    BG;

    // create a new AWTInteractionBehavior
    public AWTInteractionBehavior(
         BranchGroup bg,
         TransformGroup tg) {
        BG = bg;
        BG.setCapability(BranchGroup.ALLOW_DETACH);
        BG.setCapability(Group.ALLOW_CHILDREN_WRITE);
        BG.setCapability(Group.ALLOW_CHILDREN_EXTEND
);

//              BG.detach();

        transformGroup = tg;
        transformGroup.setCapability(
Group.ALLOW_CHILDREN_WRITE );

    }
}

    // processStimulus to rotate the cube
    public void processStimulus(Enumeration criteria)
{
        angle += Math.toRadians(10.0);
        trans.rotY(angle);
        transformGroup.setTransform(trans);
        wakeupOn(criterion);

//      BG.compile();

//      BG.detach();

        transformGroup.removeChild(0);
        transformGroup.addChild(new Sphere(0.5f));
    }
...
[/CODES]

the error is :
javax.media.j3d.RestrictedAccessException: Group: only
a BranchGroup node may be removed.

Actually I want to remove TG from a BG(BranchGroup). I
set the BG ability and tried to detach it. But it can
not work, and I really wonder why. Should I write
removeChild() in method processStimulus()? Maybe I
should not and was wrong here.

Do you have any idea about it? Where should I write
the methods detach(), compile() and removeChild()? And
what is the relationship among detach(),live,
compile() and remove()? I am really confused!

Thank you for your reading.
best regards.
tony


__________________________________________________
Do you Yahoo!?
Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!
http://platinum.yahoo.com

===========================================================================
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".

Reply via email to