Strange problems

Stéphane MOREAU moreau at adersa.asso.fr
Wed Oct 20 02:53:02 EDT 1999


    Hi vtk gurus

I use vtk2.4 with java jdk1.2 under win NT SP4.
I've got problems when I display a vtkPanel without any actor, and then
add an actor on a event (mouse click for example).
It works well when I create a vtkPanel and add an actor and then
display.
The following snippet return an exception in vtkPanel :

public class toto extends Frame implements MouseListener  {

   vtkPanel renPanel;

   //Constructor
   public toto() {
      this.addNotify();
      renPanel = new vtkPanel();
      renPanel.setSize(200,300);
      this.removeAll();
      this.add(renPanel);
      renPanel.addMouseListener(this);
   }

   //Create a sphere and add to vtkPanel
   public void foo() {
        vtkSphereSource aSphere = new vtkSphereSource();
            aSphere.SetCenter(0,0,0);
            aSphere.SetRadius(0.005);
        vtkPolyDataMapper mapper = new vtkPolyDataMapper();
            mapper.SetInput(aSphere.GetOutput());
         vtkActor actor = new vtkActor();
         actor.SetMapper(mapper);

         //Add Actor to vtkPanel
         renPanel.GetRenderer().AddActor(actor);
   }

  public void mouseClicked(MouseEvent e) {
     foo();
  }

  public static void main(String args[]) {
      toto f = new toto();
      f.pack();
      f.show();
   }
}

The example return :
Exception occurred during event dispatching:
java.lang.NullPointerException
        at vtk.vtkPanel.mouseDragged(vtkPanel.java:211)
        at java.awt.Component.processMouseMotionEvent(Unknown Source)
        at java.awt.Component.processEvent(Unknown Source)
        at java.awt.Component.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.run(Unknown Source)

When the function "foo" is before "f.pack()", it works !
Someone can help me ?
Should have add an actor before showing the vtkPanel ?


--
============================
Stéphane MOREAU
Ingénieur de recherche
ADERSA
Tél : 01-60-13-53-47
Fax : 01-69-20-05-63
mailto:moreau at adersa.asso.fr
http://www.adersa.asso.fr




-----------------------------------------------------------------------------
This is the private VTK discussion list.  Please keep messages on-topic.
Check the FAQ at: <http://www.automatrix.com/cgi-bin/vtkfaq>
To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
<majordomo at gsao.med.ge.com>.  For help, send message body containing
"info vtkusers" to the same address.     Live long and prosper.
-----------------------------------------------------------------------------




More information about the vtkusers mailing list