Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java 3D error - help.

 
Shuaib Gill
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can compile a program called StartCube.java, but when I type
java StartCube
on the command line, it will open a window with nothing in it. However it works on the schools computer. What did I do wrong? Here is the code:
// creates a universe with nothing in it.
import java.awt.*;
import java.awt.event.*;
import javax.media.j3d.*;
import com.sun.j3d.utils.universe.SimpleUniverse;
import com.sun.j3d.utils.geometry.ColorCube;
public class StartCube extends Frame {
public static void main(String[] args) {
StartCube frame = new StartCube("StartCube");
frame.setSize(300,200);
frame.setVisible(true);
}
public StartCube(String title) {
super(title);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
Canvas3D canvas = new Canvas3D(null);
add(canvas,"Center");
SimpleUniverse universe = new SimpleUniverse(canvas);
universe.getViewingPlatform().setNominalViewingTransform();
BranchGroup root = new BranchGroup();
ColorCube cube = new ColorCube(.5);
root.addChild(cube);
universe.addBranchGraph(root);
}
}
this code is right because it works on the computer at school. i have windows 2000 OS, using OpenGL java 3D API and Runtime environment.
please help.
thanks....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic