import java.applet.Applet;
import java.awt.*;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.universe.*;
import com.sun.j3d.utils.geometry.*;
import javax.media.j3d.*;
import javax.vecmath.*;

public class Simple extends Applet{
            
            public Simple() {
                    //set the layout manager for the applet
                    setLayout(new BorderLayout());
                    
                    //looks at your graphics hardware and cooks up a suitable config
                    GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
                    
                    //Canvas3D is a heavyweight component
                    Canvas3D canvas3d = new Canvas3D(config);
                    
                    //add it to this Applet
                    add("Center", canvas3d);
                    
                    //create the content branch group using the method createSceneGraph() below
                    BranchGroup scene = createSceneGraph();
                    
                    //compile 
                    //this could also be done in createSceneGraph()
                    scene.compile();
                    
                    //create a SimpleUniverse class referencing canvas3d
                    SimpleUniverse sU = new SimpleUniverse(canvas3d);
                    
                    //the view platform starts out at the orgin
                    //but our cube is also centred at the origin
                    //this moves the view platform back a bit so we can see the cube
                    sU.getViewingPlatform().setNominalViewingTransform();
                    
                    //attaches the BranchGroup to the Locale object
                    sU.addBranchGraph(scene);
                    
            }       //end of Simple (constructor)
            
            public BranchGroup createSceneGraph(){
                    BranchGroup objRoot = new BranchGroup();
                    
                    objRoot.addChild(new ColorCube(0.4));
                    
                    return objRoot;
            }       //end of createSceneGraph method of Simple
            
            public static void main(String[] args){
                    Frame frame = new MainFrame(new Simple(), 256, 256);
            }       //end of main methof of Simple
            
    } 
