Question about behavior in the RenderPeerImpl :)

So I’d been trying to figure out why I couldn’t get a Xith3D window to fit into a lightweight control, specifically a Swing JInternalFrame and now I know why.


    public CanvasPeer makeCanvas(Object owner, int width, int height, int bits,
                                 boolean fullScreen, GLCapabilities gc) {


        Frame frame = null;

        CanvasPeerImpl c = new CanvasPeerImpl(this, owner, width, height, bits, fullScreen, gc);

        if (owner == null) {
            frame = new Frame("Xith3d");
            frame.setSize(width, height);
            if (fullScreen) frame.setUndecorated(true);
            c.setWindow(frame);
            frame.add(c.getComponent());
            frame.addWindowListener(new WindowAdapter() {
                public void windowClosing(WindowEvent e) {
                    System.exit(0);
                }
            });
            frame.show();

        } else {
            Component comp = c.getComponent();
            comp.setBounds(0,0,width,height);
            ((Container)owner).add(comp);
        }

        //GLCanvas canvas = (GLCanvas) c.getComponent();

        return c;
    }

When this is used in conjunction with the stuff in the tutorials:


  CanvasPeer cp = rp.makeCanvas(null, 640, 480, 32, false); 

What you end up with is not the CanvasPeerImpl, but instead a Frame which contains the CanvasPeerImpl. Now with that said, if I wanted to ‘getContentPane().add()’ this Canvas3D to a container object - would I have to pass in the component that I want this to be a child of - that seems to be the case here.


 JFrame myJFrame = new JFrame("foo");
 ...
 CanvasPeer cp = rp.makeCanvas(myJFrame, 640, 480, 32, false);

I have a feeling that this would fail because of


            ((Container)owner).add(comp);


            panel = new JPanel();
            panel.setSize(getWidth(),getHeight());
            renderPeer = new RenderPeerImpl();
            canvasPeer = renderPeer.makeCanvas(panel,panel.getWidth(),panel.getHeight(),bits,false);
            canvas = new Canvas3D();
            canvas.set3DPeer(canvasPeer);

Working here:

http://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=xith3d;action=display;num=1075405999

Gotcha. So its using the AWT representation, and I don’t need to deal with the JComponent returned from getContentPane() and adding to it. Cool… now to see how it plays with JInternalFrame.