Like the exception says you can only add a BranchGroup while the scene
is live.

Hence in you Button action construct a cube and a BranchGroup, add the
cube to the new BranchGroup and then add this new BranchGroup to your
root.

You will probably have to do a couple of setCapacity (SP :) on the root
before making it live to allow adding children.

This should all be covered in the Sun J3D tutorial at java.sun.com and
the FAQ at www.j3d.org , they are worth a read.

Have fun,
              Jason.

>>> [EMAIL PROTECTED] 11/10/2002 10:32:13 >>>
I think I should have asked my question in a different way to prevent
confusions:

Is it possible to load a scenegraph information at a run time (please
do not think about loading any files, like VRML, with loaders)?

The attached HelloUniverse example is trying to do this by clicking the
button. I want nothing on the screen when I first run the application
but I want to see the cube when I click the button. However, I couldn't
succeeded.


In general what I am trying to do is this:
I have a database at the backgroud and I am putting different files
(CAD data) in this. During the run time, I want to select a CAD file
from this database (via a user interface) and load this information as a
scenegraph to my application. I do not want to use any loaders as the
file format does not match any of them.


Looking for your comments.

Murat


--------------------------------------------------------------------------------

I am getting the below error message when I am trying to load my
scenegraph during the run time :

C:\book>java HelloJava3Da
Button clicked
javax.media.j3d.RestrictedAccessException: Group: only a BranchGroup
node may be added
 at javax.media.j3d.Group.addChild(Group.java:259)
 at HelloJava3Da$1.actionPerformed(HelloJava3Da.java:40)
 at
javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1767)
 at
javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1820)
 at
javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:419)
 at
javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:257)
 at
javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:258)
 at java.awt.Component.processMouseEvent(Component.java:5021)
 at java.awt.Component.processEvent(Component.java:4818)
 at java.awt.Container.processEvent(Container.java:1380)
 at java.awt.Component.dispatchEventImpl(Component.java:3526)
 at java.awt.Container.dispatchEventImpl(Container.java:1437)
 at java.awt.Component.dispatchEvent(Component.java:3367)
 at
java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3214)
 at
java.awt.LightweightDispatcher.processMouseEvent(Container.java:2929)
 at java.awt.LightweightDispatcher.dispatchEvent(Container.java:2859)
 at java.awt.Container.dispatchEventImpl(Container.java:1423)
 at java.awt.Component.dispatchEvent(Component.java:3367)
 at java.awt.EventQueue.dispatchEvent(EventQueue.java:445)
 at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:190)
 at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:144)
 at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
 at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:130)
 at java.awt.EventDispatchThread.run(EventDispatchThread.java:98)

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