tags:

views:

16

answers:

0

Hi I have a scene in one frame which has 9 white spheres(3d graphics)(center).and also this frame has a panel in the north of itself which has 2d graphics . I put some check boxes on that panel and the user by clicking on them can change the color of the 3d balls .the panel also have a "reset button" button and by clicking on that ,the game will start again.BUT when the user click on that this exception will be thrown,please help me thanks

in the panel:(button has an action which calls the resetTheGame method)

  private void resetTheGame() {


            sphere.floatingWhiteSphere();
            sphere.floatingWhiteSecondSphere();
            sphere.floatingWhite3thSphere();
            sphere.floatingWhite4thSphere();
            sphere.floatingWhite5thSphere();
            sphere.floatingWhite6thSphere();
            sphere.floatingWhite7thSphere();
            sphere.floatingWhite8thSphere();
            sphere.floatingWhite9thShpere();

    }

the scene class which includes the 3d balls:(just the method will be called with the resetTheGame method in the panel)

 protected void floatingWhiteSphere() {
    // Create the blue appearance node
    Color3f black = new Color3f(0.0f, 0.0f, 0.0f);
    Color3f white = new Color3f(1.0f, 1.0f, 1.0f);
    Color3f specular = new Color3f(0.9f, 0.9f, 0.9f);

    Material blueMat = new Material(white, black, white, specular, 25.0f);
    // sets ambient, emissive, diffuse, specular, shininess
    blueMat.setLightingEnable(true);

    Appearance blueApp = new Appearance();
    blueApp.setMaterial(blueMat);

    // position the sphere
    Transform3D t3d = new Transform3D();
    t3d.set(new Vector3f(5, 1, 0));
    TransformGroup tg = new TransformGroup(t3d);
    tg.addChild(new Sphere(1.0f, blueApp));   // set its radius and appearance

    sceneBG.addChild(tg);
}

EXCEPTION:

    run:
Exception in thread "AWT-EventQueue-0" javax.media.j3d.RestrictedAccessException: Group: only a BranchGroup node may be added
        at javax.media.j3d.Group.addChild(Group.java:284)
        at checkers.WrapCheckers3D.floatingWhiteSphere(WrapCheckers3D.java:713)
        at checkers.CheckBoxChooser.resetTheGame(CheckBoxChooser.java:425)
        at checkers.CheckBoxChooser.jButton1ActionPerformed(CheckBoxChooser.java:372)
        at checkers.CheckBoxChooser.access$900(CheckBoxChooser.java:19)
        at checkers.CheckBoxChooser$10.actionPerformed(CheckBoxChooser.java:290)
        at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
        at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
        at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
        at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
        at java.awt.Component.processMouseEvent(Component.java:6038)
        at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
        at java.awt.Component.processEvent(Component.java:5803)
        at java.awt.Container.processEvent(Container.java:2058)
        at java.awt.Component.dispatchEventImpl(Component.java:4410)
        at java.awt.Container.dispatchEventImpl(Container.java:2116)
        at java.awt.Component.dispatchEvent(Component.java:4240)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
        at java.awt.Container.dispatchEventImpl(Container.java:2102)
        at java.awt.Window.dispatchEventImpl(Window.java:2429)
        at java.awt.Component.dispatchEvent(Component.java:4240)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)