Hello,

Attached is a short program that should (as far as I know) implement
a java3d window as a JPanel.  However, it does not.
Any suggestions.

Steve


//////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////
import java.awt.*;
import java.awt.event.*;
import java.awt.event.WindowAdapter;
import javax.swing.*;
import javax.swing.JFrame;

public class MethodView extends JFrame {

    Container contentpane;
  protected JPanel ivjJPanel1 = null;

  MethodNode MethodRoot = new MethodNode();

    public MethodView(String name,int x,int y,int h,int w)
    {
      super(name);
      this.setBounds(x,y,h,w);

      this.addWindowListener(new WindowAdapter() {
                                          public void windowClosing(WindowEvent e){
                                                  System.exit(0);
                                          }});

      contentpane = this.getContentPane();

      MethodPanel3D methPanel = new MethodPanel3D();
      contentpane.add("Center",methPanel);

      this.show();
   }

    public static void main(String[] args)
    {
        JFrame frame = new MethodView("Test for Java3D panel",50,50,500,500);
    }
}
//////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

import com.sun.j3d.utils.universe.*;
import com.sun.j3d.utils.geometry.*;
import javax.media.j3d.*;
import javax.vecmath.*;

import com.sun.j3d.utils.geometry.ColorCube;


class MethodPanel3D extends JPanel
{
   Canvas3D canvas;

    public MethodPanel3D()
    {
    setOpaque(false);

      canvas = new Canvas3D(SimpleUniverse.getPreferredConfiguration());
     BranchGroup scene = createSceneGraph();
     SimpleUniverse u = new SimpleUniverse(canvas);
      u.getViewingPlatform().setNominalViewingTransform();
     u.addBranchGraph(scene);

      add("Center",canvas);

    }

    public BranchGroup createSceneGraph()
    {
     BranchGroup objRoot = new BranchGroup();

    objRoot.addChild( new ColorCube(0.4) );

    return objRoot;
    }

/*
    public void paintComponent(Graphics g)
    {
        super.paintComponent(g);
        g.drawString("test",50,50);
    }
*/

}
//////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to