帮助!当我尝试启动我的.class文件时,我看到应用程序弹出窗口,然后退出。我没有看到我的宝贵工作!有人可以查看下面的代码并告诉我我做错了吗?
import com.sun.j3d.utils.universe.SimpleUniverse;
import com.sun.j3d.utils.geometry.ColorCube;
import javax.media.j3d.BranchGroup;
public class Hello3d {
public Hello3d()
{
SimpleUniverse universe = new SimpleUniverse();
BranchGroup group = new BranchGroup();
group.addChild(new ColorCube(0.3));
universe.getViewingPlatform().setNominalViewingTransform();
universe.addBranchGraph(group);
}
public static void main(String[] args) {
//Schedule a job for the event-dispatching thread:
//creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
new Hello3d();
}
});
}
} // end of class Hello3d
答案 0 :(得分:1)
我尽可能正确地设置你的场景,但你没有创造任何方法向用户展示它(窗口,画布等)。
从您的代码中,我假设您一直关注this tutorial,这是正确的吗?检查Java 3D and the User Interface(在同一网站中提前几页)以了解如何执行此操作。