1
我有一个用于绘制三维对象的Canvas3D类的应用程序。画布背景默认为黑色。我想改变它,但我不知道如何。我从互联网上找到了一段代码,但它不起作用。这里是代码:如何设置Canvas3D背景颜色?
setLayout(new BorderLayout());
GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
canvas = new Canvas3D(config);
JPanel centerPanel = new JPanel(new GridLayout(1, 1));
centerPanel.setBorder(BorderFactory.createLineBorder(Color.black));
centerPanel.add(canvas);
universe = new SimpleUniverse(canvas);
Background newBk = new Background(new Color3f(Color.WHITE));
newBk.setApplicationBounds(new BoundingSphere(new Point3d(0f,0f,0f), 100));
canvas.getGraphicsContext3D().setBackground(newBk);
你对这个问题有帮助吗?
在此先感谢。
非常感谢。我解决了我的问题。 – Hassan 2012-03-10 13:11:17
Welcme。如果你有任何资讯我的答案,请加入或加注。否则,你可以离开这个 – 2012-03-10 13:25:17