[vtkusers] NullpointerException with vtkPanel

Marius Hennecke M.Hennecke at web.de
Sun Feb 27 09:33:02 EST 2005


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

I have a problem with vtkPanel. I've donwloaded the nightlies and
everything compiled (after a few hours of trouble ;) )

I have compiled with Java wrapping. The Cone.java example works fine, so
I expect my vtk Base-Installation is not the problem.

I had to compile and pack the Java wrapping stuff manually into vtk.jar
it wasn't done by make. I've added the compiled vtkPanel and vtkCanvas
classes to vtk.jar, too.

This piece of code crashes at the line where the actor is added to the
renderer of the panel. Without this line the file compiles but nothing
is shown :)


package aufgaben;

import java.awt.FlowLayout;
import javax.swing.JFrame;
import vtk.*;

public class Aufgabe_Kegel_1 {
~    static {
~        System.loadLibrary("vtkCommonJava");
~        System.loadLibrary("vtkFilteringJava");
~        System.loadLibrary("vtkIOJava");
~        System.loadLibrary("vtkImagingJava");
~        System.loadLibrary("vtkGraphicsJava");
~        System.loadLibrary("vtkRenderingJava");
~    }

~    public static void main(String[] args) {
~        JFrame aFrame = new JFrame();
~        aFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
~        aFrame.getContentPane().setLayout(new FlowLayout());

~        vtkPanel thePanel = new vtkPanel();
~        aFrame.getContentPane().add(thePanel);

~        vtkConeSource srcCone = new vtkConeSource();
~        srcCone.SetHeight(3);
~        srcCone.SetRadius(1);
~        srcCone.SetResolution(10);

~        vtkPolyDataMapper pdmMapper = new vtkPolyDataMapper();
~        pdmMapper.SetInput(srcCone.GetOutput());

~        vtkActor coneActor = new vtkActor();
~        coneActor.SetMapper(pdmMapper);
~        coneActor.GetProperty().SetColor(.0, .0, 1.0);

~        //NullpointerException Here
~        thePanel.GetRenderer().AddActor(coneActor);

~        aFrame.pack();
~        aFrame.setVisible(true);
~    }
}

This is the stack trace
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
	at vtk.vtkPanel.UnLock(Native Method)
	at vtk.vtkPanel.Render(vtkPanel.java:135)
	at vtk.vtkPanel.paint(vtkPanel.java:155)
	at sun.awt.RepaintArea.paintComponent(RepaintArea.java:248)
	at sun.awt.X11.XRepaintArea.paintComponent(XRepaintArea.java:56)
	at sun.awt.RepaintArea.paint(RepaintArea.java:224)
	at Sun.awt.X11.XComponentPeer.handleEvent(XComponentPeer.java:632)
	at java.awt.Component.dispatchEventImpl(Component.java:4031)
	at java.awt.Component.dispatchEvent(Component.java:3803)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
	at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234)
	at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)


I'm running JRE 1.5.0.01 on a Gentoo 2.6.10-r5 box.

mfg
Marius Hennecke
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCIdoe+STWoLopCpURAm4GAJ9Dfm5PQxS/2N6rGs4/cBUO2JCwPACcCe1e
DpH6Ags125Maj2Fha1m3xcA=
=MLj+
-----END PGP SIGNATURE-----



More information about the vtkusers mailing list