帮助!当我尝试启动.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发布于 2012-05-30 09:38:15
据我所知,您设置的场景是正确的,但是您没有创建任何方法来向用户显示它(窗口、画布等)。
从你的代码中,我假设你一直在关注this tutorial,对吗?查看Java 3D and the User Interface (在同一站点前面的几个页面),了解如何做到这一点。
https://stackoverflow.com/questions/10808865
复制相似问题