[vtkusers] vtk and Java : problem when remove a vtkactor to avtkrenderer or add avtkrenderer to a vtkrenderwindow
Jeff Lee
jeff at cdnorthamerica.com
Wed Jul 9 08:41:34 EDT 2003
see below...
Romain Ollivier wrote:
>For my viewer, I use the class myVtkPanel wich extends vtkPanel with :
>
> public void removeActor(vtkProp actor)
> {
> Lock();
> ren.RemoveActor(actor);
> UnLock();
> }
>
> public void addActor(vtkProp actor)
> {
> Lock();
> ren.AddActor(actor);
> UnLock();
> }
>
>Then, I have a myVtkJPanel class, wich extends a JPanel, containing this :
>
>........
> private myVtkPanel view;
>........
> public void addActor(vtkProp actor)
> {
> view.addActor(actor);
> }
>
> public void removeActor(vtkProp actor)
> {
> view.removeActor(actor);
> }
>
>
> My viewer use an instance of this JPanel. When I call the addActor() function in my viewer
>constructor, I get this :
>
>Exception in thread "main" java.lang.IllegalMonitorStateException: current thread not owner
> at vtk.vtkPanel.UnLock(Native Method)
> at myVtkPanel.addActor(myVtkPanel.java:33)
> at myVtkJPanel.addActor(myVtkJPanel.java:82)
> at myViewer.makeDataPanel(myViewer.java:86)
> at myViewer.<init>(myViewer.java:62)
> at myViewer.main(myViewer.java:190)
>
>Do you know what I'm doing wrong when I use Lock() an UnLock() ?
>
tough to say without seeing the whole code, but I'd guess that you are
trying to add the actor before the drawing surface has been created.
there is no need to lock in your addActor method anyway - take it out.
also be careful of doing things like that in a constructor unless you
are sure that the canvas has gone through its proper initialization.
-Jeff
More information about the vtkusers
mailing list