# Java3D in ein JPanel integrieren mit Netbeans 6.8



## Silentday (1. Jun 2010)

Hallo Leute,

ich steh vor einem großen Problem. Ich will eine 3D Visualisierung, die von einem Kollegen implementiert wurde in meine GUI integrieren. Ziel ist es das ich sie in ein JPanel bekomme.

Die Visualisierung verwendet einen Graphen zur Darstellung von Beziehungen zwischen Personen mit Knoten und Kanten.

Die Visualisierung hatte er derweil als eigenständige Klasse (als Applet) geschrieben, doch nun soll sie halt in meine SWING - Oberfläche integriert werden.

Muss ich da vielleicht was mit einem AWT Canvas machen oder nur das JPanel erweitern oder ... ??? keine ahnung. habe shcon stunden mit der suche verbracht.

Ich verwende Netbeans 6.8 und habe nicht wirklich einen Plan von Java3D.

Der Code zum Graphen (Visualisierung) lautet:



```
package java3d;

import app.Edge;
import app.Graph;
import app.Person;
import java.applet.Applet;
import java.awt.BorderLayout;
import java.awt.Frame;
import java.awt.GraphicsConfiguration;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.Vector;

import javax.media.j3d.AmbientLight;
import javax.media.j3d.Appearance;
import javax.media.j3d.BoundingSphere;
import javax.media.j3d.BranchGroup;
import javax.media.j3d.Canvas3D;
import javax.media.j3d.ColoringAttributes;
import javax.media.j3d.DirectionalLight;
import javax.media.j3d.Geometry;
import javax.media.j3d.LineArray;
import javax.media.j3d.Material;
import javax.media.j3d.Node;
import javax.media.j3d.Font3D;
import javax.media.j3d.PickInfo;
import javax.media.j3d.Shape3D;
import javax.media.j3d.Text3D;
import javax.media.j3d.Transform3D;
import javax.media.j3d.TransformGroup;
import javax.vecmath.Color3f;
import javax.vecmath.Point3d;
import javax.vecmath.Point3f;
import javax.vecmath.Vector3f;

import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.behaviors.mouse.MouseRotate;
import com.sun.j3d.utils.behaviors.mouse.MouseTranslate;
import com.sun.j3d.utils.behaviors.mouse.MouseZoom;
import com.sun.j3d.utils.geometry.ColorCube;
import com.sun.j3d.utils.geometry.Cone;
import com.sun.j3d.utils.geometry.Primitive;
import com.sun.j3d.utils.geometry.Sphere;
import com.sun.j3d.utils.pickfast.PickCanvas;
import com.sun.j3d.utils.pickfast.behaviors.PickTranslateBehavior;
import com.sun.j3d.utils.picking.PickResult;
import com.sun.j3d.utils.universe.SimpleUniverse;


public class VisualFunctions extends Applet implements MouseListener {



	private static final long serialVersionUID = 1L;
	private PickCanvas pickCanvas;
	private Vector<Vector> vec = new Vector<Vector>();
	Graph<Person> gr;
	TransformGroup root;


	public VisualFunctions(Graph<Person> graph){

		gr = graph;
		setLayout(new BorderLayout());
	 GraphicsConfiguration config =
		 SimpleUniverse.getPreferredConfiguration();
		 Canvas3D canvas3D = new Canvas3D(config);
		 add("Center", canvas3D);

		 BranchGroup scene = createSceneGraph(graph,canvas3D);
		 scene.compile();

		 SimpleUniverse simpleU = new SimpleUniverse(canvas3D);
		 simpleU.getViewingPlatform().setNominalViewingTransform();

		 simpleU.addBranchGraph(scene);
		}


	public BranchGroup createSceneGraph(Graph<Person> graph,Canvas3D canvas3D) {
		 // Create the root of the branch graph
		 BranchGroup objRoot = new BranchGroup();

		/* objRoot.setCapability(BranchGroup.ALLOW_CHILDREN_WRITE);
		 objRoot.setCapability(BranchGroup.ALLOW_CHILDREN_READ);
		 objRoot.setCapability(Shape3D.ALLOW_APPEARANCE_READ);
		 objRoot.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE);
		 */

		 TransformGroup rootTrans = new TransformGroup();
		 objRoot.addChild(rootTrans);
		 rootTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
		 rootTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
		 rootTrans.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
		 rootTrans.setCapability(TransformGroup.ALLOW_CHILDREN_WRITE);
		 rootTrans.setCapability(TransformGroup.ALLOW_CHILDREN_READ);
		 rootTrans.setCapability(Shape3D.ALLOW_APPEARANCE_READ);
		 rootTrans.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE);



		 MouseRotate myMouseRotate = new MouseRotate();
		 myMouseRotate.setTransformGroup(rootTrans);
		 myMouseRotate.setSchedulingBounds(new BoundingSphere());
		 rootTrans.addChild(myMouseRotate);

		 Appearance appearance = new Appearance();
		 Appearance appearance2 = new Appearance();


		 Color3f red = new Color3f(1.0f, 0.0f, 0.0f);
		 Color3f blue = new Color3f(0,0,255);
		 Color3f white = new Color3f(255,255,255);
		 Color3f yellow = new Color3f(255,255,0);
		 appearance2.setMaterial(new Material(yellow,yellow,red,yellow,8.0f));
		 appearance.setMaterial(new Material(blue,blue,blue,red, 8.0f));
		 BoundingSphere behaveBounds = new BoundingSphere();

		 Transform3D rotate = new Transform3D();
		Transform3D translate = new Transform3D();


		//PICK ZEUGS

		pickCanvas = new PickCanvas(canvas3D, objRoot);

	    pickCanvas.setMode(PickCanvas.TYPE_SHAPE3D);
	    canvas3D.addMouseListener(this);

	    MouseZoom myMouseZoom = new MouseZoom();
		 myMouseZoom.setTransformGroup(rootTrans);
		 myMouseZoom.setSchedulingBounds(new BoundingSphere());
		 rootTrans.addChild(myMouseZoom);

		 MouseRotate myMouseRotatee = new MouseRotate();
		 myMouseRotatee.setTransformGroup(rootTrans);
		 myMouseRotatee.setSchedulingBounds(new BoundingSphere());
		 rootTrans.addChild(myMouseRotatee);


		for(Person p: graph.getNodes()){

			float x = (float) (Math.random()*(0.6 + 0.6)- 0.6);
		    float y = (float) (Math.random()*(0.6 + 0.6)- 0.6);
		    float z = (float) (Math.random()*(0.6 + 0.6)- 0.6);

			Vector3f v3f = new Vector3f(x,y,z);
		translate.setTranslation(v3f);
		//rotate.rotY(Math.PI/4.0d);
		//rotate.mul(translate);
		rotate.setTranslation(v3f);
		 ColorCube cb = new ColorCube(0.01);
		 TransformGroup objRotate = new TransformGroup(rotate);
		 objRotate.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
		 objRotate.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
		 objRotate.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
		 objRotate.setCapability(TransformGroup.ALLOW_CHILDREN_WRITE);
		 objRotate.setCapability(TransformGroup.ALLOW_CHILDREN_READ);
		 //objRoot.addChild(drawLine(v3f, new Vector3f(0.01f,0.01f,0.01f),red, 0.01));


	/*	 Text3D text = new Text3D();
		 text.setString(p.getName());
		 text.setPosition(new Point3f(x,y,z));
		 //objRoot.addChild((Shape3D)text);
		 */


		 if(p.getType()==0){

			 Sphere sphere = new Sphere((float) 0.08,  appearance2);
			 sphere.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE);
			 sphere.setCapability(Shape3D.ALLOW_APPEARANCE_READ);
			 sphere.setCapability(Shape3D.ALLOW_APPEARANCE_OVERRIDE_WRITE);
			 sphere.setCapability(Shape3D.ALLOW_APPEARANCE_OVERRIDE_READ);
			 sphere.setCapability(Node.ENABLE_PICK_REPORTING);
			// sphere.setCapability(Primitive.ENABLE_APPEARANCE_MODIFY);


			 objRotate.addChild(sphere);

			 Vector triple = new Vector();
			 triple.add(p);
			 triple.add(sphere);
			 triple.add(v3f);
			 vec.add(triple);

		 }else{
			Cone cone = new Cone(0.1f,0.15f,  appearance);

			cone.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE);
			cone.setCapability(Shape3D.ALLOW_APPEARANCE_READ);
			cone.setCapability(Shape3D.ALLOW_APPEARANCE_OVERRIDE_WRITE);
			cone.setCapability(Shape3D.ALLOW_APPEARANCE_OVERRIDE_READ);
			cone.setCapability(Node.ENABLE_PICK_REPORTING);
			cone.setCapability(Primitive.ENABLE_APPEARANCE_MODIFY);
            //cone.setPerson(p);
			 objRotate.addChild(cone);

			 Vector triple = new Vector();
			 triple.add(p);
			 triple.add(cone);
			 triple.add(v3f);
			 vec.add(triple);
		 }


		 AmbientLight aLight = new AmbientLight(white);
		 BoundingSphere bounds = new BoundingSphere
		 (new Point3d(), 100000);
		 aLight.setInfluencingBounds(bounds);
		 DirectionalLight dLight = new DirectionalLight
		 (new Color3f(255,255,0), new Vector3f(-0.5f, -0.5f, -0.5f));
		 dLight.setInfluencingBounds(bounds);
		objRoot.addChild(aLight);
		 objRoot.addChild(dLight);
		 // Create a simple shape leaf node, add it to the scene graph.
		 // ColorCube is a Convenience Utility class
		 rootTrans.addChild(objRotate);

		 PickTranslateBehavior pickTranslate = new PickTranslateBehavior(objRoot,canvas3D, behaveBounds);
		 objRotate.addChild(pickTranslate);

		}

		for(Edge e : graph.getEdges()){

			Vector3f v31 = null;
			Vector3f v32 = null;

			float[] f1 = new float[3];
			float[] f2 = new float[3];

			for(Vector v:vec){

				if(v.contains(e.get(0))){
					v31 = getPosition((Node)v.get(1));
				}

				else if(v.contains(e.get(1))){
					v32 = getPosition((Node)v.get(1));
				}
			}

			v31.get(f1);
			v32.get(f2);

			Appearance appe = new Appearance();
			ColoringAttributes Coloring = new ColoringAttributes();



			if(((Person) e.get(0)).getType() + ((Person) e.get(1)).getType() == 0){

				Coloring.setColor(red);
				appe.setColoringAttributes(Coloring);

			}
			else if(((Person) e.get(0)).getType() + ((Person) e.get(1)).getType() == 1){
				Coloring.setColor(blue);
				appe.setColoringAttributes(Coloring);
				}
			else{
				Coloring.setColor(yellow);
				appe.setColoringAttributes(Coloring);
			}

			Point3f[] plaPts = new Point3f[2];
		    plaPts[0] = new Point3f(f1[0], f1[1], f1[2]);
		    plaPts[1] = new Point3f(f2[0], f2[1], f2[2]);
		    LineArray pla = new LineArray(2, LineArray.COORDINATES);
		    pla.setCoordinates(0, plaPts);
		    Shape3D plShape = new Shape3D(pla, appe);
		    rootTrans.addChild(plShape);
		}

		/* MouseRotate myMouseRotate = new MouseRotate();
		 myMouseRotate.setTransformGroup(rootTrans);
		 myMouseRotate.setSchedulingBounds(new BoundingSphere());
		 rootTrans.addChild(myMouseRotate);
		objRoot.addChild(rootTrans); */

		root = rootTrans;
		objRoot.compile();
		 return objRoot;
		 }


	public Vector3f getPosition(Node shape)
    {
        Transform3D positionTrans = new Transform3D();
        shape.getLocalToVworld(positionTrans);

        Vector3f locationVec = new Vector3f();
        positionTrans.get(locationVec);

        float[] flo = new float[3];
        locationVec.get(flo);
        System.out.print(flo[0] + " ");
        System.out.print(flo[1] + " ");
        System.out.println(flo[2]);

        return locationVec;
    }




	public static void main (String[] args) {

		Person p1 = new Person(0, "Hans", "Maier", "12");
		Person p2 = new Person(1, "Peter", "Huber", "13");
		Person p3 = new Person(0,"Thomas", "Bauer", "14");
		Person p4 = new Person(1, "Dominik", "Imsirovic", "15");

		p2.addAttribut("mobil", "06761111");

		Edge<Person> e = new Edge<Person>(p1,p2);
		Edge<Person> e2 = new Edge<Person>(p2,p3);
		Edge<Person> e3 = new Edge<Person>(p3,p4);
		Edge<Person> e4 = new Edge<Person>(p2,p4);

		Vector<Person> v = new Vector<Person>();

		v.add(p1);
		v.add(p2);
		v.add(p3);
		v.add(p4);
		Vector<Edge<Person>> edges = new Vector<Edge<Person>>();
		edges.add(e);
		edges.add(e2);
		edges.add(e3);
		edges.add(e4);

		Graph<Person> graph = new Graph<Person>(v,edges);

		Frame frame = new MainFrame(new VisualFunctions(graph), 256, 256);
		}


	public void mouseClicked(MouseEvent e)

	{

	    pickCanvas.setShapeLocation(e);

	    PickInfo result = pickCanvas.pickClosest();

	    if (result == null) {

	       System.out.println("Nothing picked");

	    } else {

	    	getPosition((Node) result.getNode());

	    	for(Vector v : vec){
	    		if (((Geometry)v.get(1)).equals(((Shape3D)result.getNode()).getGeometry())){
	    			System.out.println(((Person)v.get(0)).getName());
	    		}
	    	}

	    //	System.out.println(((SpherePerson)((Shape3D)result.getNode()).getGeometry()).getPerson().getName());


			}



	      // Primitive p = (Primitive)result.getNode();

        	       //Shape3D s = (Shape3D)result.getNode();

	       //if (p != null) {

	         // System.out.println(p.getClass().getName());

	       /*} else */ /*if (result.getNode() != null) {

	    	   Appearance newapp = new Appearance();
	    	   Color3f white = new Color3f(255,255,255);

	    	   newapp.setMaterial(new Material(white,white,white,white,0.8f));

	    	   Appearance appii = new Appearance();
	    	   Color3f bu = new Color3f(0,0,255);

	    	   appii.setMaterial(new Material(bu,bu,bu,bu,0.8f));
	             System.out.println(result.getNode().getClass().getName());

	             if(result.getNode() instanceof Shape3D){
	             //((Shape3D) result.getNode()).setAppearance(newapp);


	             //((Shape3D) result.getNode()).setAppearance(appii);
	             }

	       } else{

	          System.out.println("null");

	       }*/

	    }





	@Override
	public void mouseEntered(MouseEvent arg0) {
		// TODO Auto-generated method stub

	}


	@Override
	public void mouseExited(MouseEvent arg0) {
		// TODO Auto-generated method stub

	}


	@Override
	public void mousePressed(MouseEvent arg0) {
		// TODO Auto-generated method stub

	}


	@Override
	public void mouseReleased(MouseEvent arg0) {
		// TODO Auto-generated method stub

	}


}
```



Bitte um schnelle Hilfe da ich bis morgen dieses Problem gelöst haben muss


----------



## Marco13 (1. Jun 2010)

Am Anfang vielleicht sowas in der Richtung...

```
public static void main(String[] args)
    {
        SwingUtilities.invokeLater(new Runnable()
        {
            public void run()
            {
                JFrame frame = new JFrame();
                frame.getContentPane().setLayout(new BorderLayout());
                VisualFunctions v = new VisualFunctions();
                frame.getContentPane().add(v.getCanvas(), BorderLayout.CENTER);
                frame.setSize(500,500);
                frame.setVisible(true);
            }
        });
    }
    
    private Canvas3D canvas3D;
    
    public Canvas3D getCanvas()
    {
        return canvas3D;
    }
    
    public VisualFunctions()
    {
        GraphicsConfiguration config = SimpleUniverse
            .getPreferredConfiguration();
        canvas3D = new Canvas3D(config);

...
```

Swing und AWT (Canvas3D) mischen kann aber unerwünschte Effekte nach sich ziehen (Übermalen von Swing-Components und so...)


----------



## Silentday (1. Jun 2010)

Hy danke Marco für die schnele Antwort!

ich bräuchte eher was in die richtung.

hier ist der Code von einem kleinen Fenster das aus einem Menü einem TexArea und einem JPanel bestet.

ich hätte die visualisierung (Java3d) gerne im JPanel


lg

```
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * NewApplication.java
 *
 * Created on 01.06.2010, 17:46:20
 */

package gui;

/**
 *
 * @author Schatzi
 */
public class NewApplication extends javax.swing.JFrame {

    /** Creates new form NewApplication */
    public NewApplication() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

        jFrame1 = new javax.swing.JFrame();
        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();
        menuBar = new javax.swing.JMenuBar();
        fileMenu = new javax.swing.JMenu();
        openMenuItem = new javax.swing.JMenuItem();
        exitMenuItem = new javax.swing.JMenuItem();
        editMenu = new javax.swing.JMenu();
        cutMenuItem = new javax.swing.JMenuItem();
        copyMenuItem = new javax.swing.JMenuItem();
        pasteMenuItem = new javax.swing.JMenuItem();
        deleteMenuItem = new javax.swing.JMenuItem();
        helpMenu = new javax.swing.JMenu();
        contentsMenuItem = new javax.swing.JMenuItem();
        aboutMenuItem = new javax.swing.JMenuItem();

        jFrame1.setName("jFrame1"); // NOI18N

        javax.swing.GroupLayout jFrame1Layout = new javax.swing.GroupLayout(jFrame1.getContentPane());
        jFrame1.getContentPane().setLayout(jFrame1Layout);
        jFrame1Layout.setHorizontalGroup(
            jFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        jFrame1Layout.setVerticalGroup(
            jFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 300, Short.MAX_VALUE)
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setName("Form"); // NOI18N

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(""));
        jPanel1.setName("jPanel1"); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 204, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 244, Short.MAX_VALUE)
        );

        jPanel2.setName("jPanel2"); // NOI18N

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 257, Short.MAX_VALUE)
        );

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        jTextArea1.setColumns(20);
        jTextArea1.setRows(5);
        jTextArea1.setName("jTextArea1"); // NOI18N
        jScrollPane1.setViewportView(jTextArea1);

        menuBar.setName("menuBar"); // NOI18N

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(gui.mfbMain.class).getContext().getResourceMap(NewApplication.class);
        fileMenu.setText(resourceMap.getString("fileMenu.text")); // NOI18N
        fileMenu.setName("fileMenu"); // NOI18N

        openMenuItem.setText(resourceMap.getString("openMenuItem.text")); // NOI18N
        openMenuItem.setName("openMenuItem"); // NOI18N
        fileMenu.add(openMenuItem);

        exitMenuItem.setText(resourceMap.getString("exitMenuItem.text")); // NOI18N
        exitMenuItem.setName("exitMenuItem"); // NOI18N
        exitMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                exitMenuItemActionPerformed(evt);
            }
        });
        fileMenu.add(exitMenuItem);

        menuBar.add(fileMenu);

        editMenu.setText(resourceMap.getString("editMenu.text")); // NOI18N
        editMenu.setName("editMenu"); // NOI18N

        cutMenuItem.setText(resourceMap.getString("cutMenuItem.text")); // NOI18N
        cutMenuItem.setName("cutMenuItem"); // NOI18N
        editMenu.add(cutMenuItem);

        copyMenuItem.setText(resourceMap.getString("copyMenuItem.text")); // NOI18N
        copyMenuItem.setName("copyMenuItem"); // NOI18N
        editMenu.add(copyMenuItem);

        pasteMenuItem.setText(resourceMap.getString("pasteMenuItem.text")); // NOI18N
        pasteMenuItem.setName("pasteMenuItem"); // NOI18N
        editMenu.add(pasteMenuItem);

        deleteMenuItem.setText(resourceMap.getString("deleteMenuItem.text")); // NOI18N
        deleteMenuItem.setName("deleteMenuItem"); // NOI18N
        editMenu.add(deleteMenuItem);

        menuBar.add(editMenu);

        helpMenu.setText(resourceMap.getString("helpMenu.text")); // NOI18N
        helpMenu.setName("helpMenu"); // NOI18N

        contentsMenuItem.setText(resourceMap.getString("contentsMenuItem.text")); // NOI18N
        contentsMenuItem.setName("contentsMenuItem"); // NOI18N
        helpMenu.add(contentsMenuItem);

        aboutMenuItem.setText(resourceMap.getString("aboutMenuItem.text")); // NOI18N
        aboutMenuItem.setName("aboutMenuItem"); // NOI18N
        helpMenu.add(aboutMenuItem);

        menuBar.add(helpMenu);

        setJMenuBar(menuBar);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 257, Short.MAX_VALUE))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>

    private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) {                                             
        System.exit(0);
    }                                            

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new NewApplication().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify
    private javax.swing.JMenuItem aboutMenuItem;
    private javax.swing.JMenuItem contentsMenuItem;
    private javax.swing.JMenuItem copyMenuItem;
    private javax.swing.JMenuItem cutMenuItem;
    private javax.swing.JMenuItem deleteMenuItem;
    private javax.swing.JMenu editMenu;
    private javax.swing.JMenuItem exitMenuItem;
    private javax.swing.JMenu fileMenu;
    private javax.swing.JMenu helpMenu;
    private javax.swing.JFrame jFrame1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextArea jTextArea1;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JMenuItem openMenuItem;
    private javax.swing.JMenuItem pasteMenuItem;
    // End of variables declaration

}
```


----------



## Marco13 (1. Jun 2010)

Ohne das jetzt durchgelesen oder getestet zu haben:

```
VisualFunctions v = new VisualFunctions();
Component canvas = v.getCanvas();
woAuchImmerDuDenHinzufügenWillst.add(canvas);
```


----------



## Silentday (5. Jun 2010)

Danke Marco! Jetzt gehts.

lg Niklas


----------

