I am trying to insert a Canvas3D object inside a Swing JPanel, but the code does not seem to work (i.e. nothing happens):
Canvas3D canvas = new Canvas3D (SimpleUniverse.getPreferredConfiguration ());
SimpleUniverse universe = new SimpleUniverse (canvas);
BranchGroup root = new BranchGroup ();
root.addChild (new ColorCube ());
universe.addBranchGraph (root);
universe.getViewingPlatform (). setNominalViewingTransform ();
canvasPanel.add (canvas);
What am I missing? JPanel was created using the NetBean Visual Editor.
java swing java-3d
Edward Z. Yang
source share