[vtkusers] trying to use vtk with java
Frederic Kleinermann
F.Kleinermann at pgr.salford.ac.uk
Mon Sep 11 13:53:22 EDT 2000
Hi,
I am trying to use vtk with java. So far, I cannot make a simple example
using VTK working with java. I have managed to compile the library vtk
under java. I have managed to compile vtkPanel.java. Now I have tried to
run a simple example :
import vtk.*;
public class TestVTK {
public static void main ( String args[] )
{
vtkPanel panel = new vtkPanel();
vtkConeSource cone=new vtkConeSource();
cone.SetResolution(8);
vtkPolyDataMapper coneMapper=new vtkPolyDataMapper();
coneMapper.SetInput(cone.GetOutput());
vtkActor coneActor=new vtkActor();
coneActor.SetMapper(coneMapper);
panel.setActor(coneActor);
}
}
When I type the command : java TestVTK , it complains saying :
Exception in thread "main" java.lang.NullPointerException:
at vtkPanel.getWindowID(vtkPanel.java:59)
at vtkPanel.getWindowInfo(vtkPanel.java:83)
at vtkPanel.Render(vtkPanel.java:115)
at vtkPanel.setActor(vtkPanel.java:32)
at TestVTK.main(TestVTK.java:18)
it seems that the problem comes from the following three lines in
vtkPanel.java :
Win32DrawingSurface wds =
(Win32DrawingSurface)surfaceInfo.getSurface();
int hWnd = wds.getHWnd();
I have also tried to run it from an applet like this :
import vtk.*;
import java.applet.Applet;
import java.awt.Graphics;
public class TestVTK extends Applet{
public static void main ( String args[] )
{
vtkPanel panel = new vtkPanel();
vtkConeSource cone=new vtkConeSource();
cone.SetResolution(8);
vtkPolyDataMapper coneMapper=new vtkPolyDataMapper();
coneMapper.SetInput(cone.GetOutput());
vtkActor coneActor=new vtkActor();
coneActor.SetMapper(coneMapper);
panel.setActor(coneActor);
}
}
using the command
apletviewer TestVTK
The problem is that the appletviewer appears. But there is no cone which
is rendered.
I wonder if someone had a similar problem. Since I am not very
experienced with java, I will be very interested to know how to solve
that problem.
Thanks.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: F.Kleinermann.vcf
Type: text/x-vcard
Size: 567 bytes
Desc: Card for Frederic Kleinermann
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20000911/f7a80ad2/attachment.vcf>
More information about the vtkusers
mailing list