Search code examples
javanetbeanscanvasnetbeans6.7java-3d

Using NetBeans IDE 6.7 with J3D's Canvas3D Container


I keep telling myself that this should be simple, and yet I'm completely lost. Let me start by saying that I'm new to NetBeans IDE, and that I am using it out of necessity. I don't really know much about it yet.

I have successfully designed my main window for my application. The right side of the application is essentially a large window into a three-dimensional space that visualizes certain transforms on data sets. I have searched through the palette and the palette manager and even tried to add the Canvas3D component to the palette manually from a JAR, but I still can't get it.

I would really like to be able to drag and drop this component into my application, and intuitively, it seems possible. I'm on Mac OS X; the output from my About NetBeans tells more.

Product Version: NetBeans IDE 6.7 (Build 200906241340)
Java: 1.5.0_19; Java HotSpot(TM) Client VM 1.5.0_19-137
System: Mac OS X version 10.5.7 running on i386; MacRoman; en_US (nb)
Userdir: /Users/dremelofdeath/.netbeans/6.7

Thanks in advance for helping me out -- I really appreciate it.


Solution

  • The Canvas3D is a heavyweight component meaning it uses a native peer component to hook into DirectX or OpenGL so probably this kind of component is not available for drag and drop. Though you could try extending a JPanel.

    You can setup the layout manually quite easily using a BoderLayout.

    MyFrame extends JFrame {
    
    etc...
    
     Container container = getContentPane();
     container.setName("main.container");
     container.setLayout(new BorderLayout());
    
     container.add(new MyCanvasPanel(), BorderLayout.CENTER);
    
    }  
    
    // this could probably be added to the palete
    public class MyCanvasPanel extends JPanel {
    
        SimpleUniverse su;
        Canvas3D canvas3D;
    
      public MyCanvasPanel() {
            canvas3D = new Canvas3D(SimpleUniverse.getPreferredConfiguration());
            add("Center", canvas3D);
            su = new SimpleUniverse(canvas3D);
      }
    
    }