[vtkusers] VTK + Java Swing

egk865 at yahoo.com egk865 at yahoo.com
Thu Oct 21 13:04:23 EDT 2010


Combining heavyweight and lightweight components seems to be very well supported in recent versions of Java (see e.g. http://java.sun.com/developer/technicalArticles/GUI/mixing_components/index.html) and I've never had any real problems with it. What difficulties are you experiencing? 

Eli


> I am trying to put a vtkCanvas into a
> Swing application.  As you know
> vtkCanvas extends vtkPanel which extends
> java.awt.Canvas.  This is a
> heavyweight Java UI component.  Swing is composed of
> lightweight components.
>  It turns out that mixing heavy and light components is
> very difficult to
> create an application that works well.
> 
> I tried editing the vtkPanel class to extend JPanel instead
> of Canvas, and
> changed the name of the paint(Graphics g) method to
> paintComponent(Graphics
> g), and verified that indeed it is getting called. 
> However it does not
> paint the vtkPanels into the swing components, instead it
> paints them in
> their own VTK windows.
> 
> After more investigation I found the file vtkJavaAwt.h
> which defines the
> native method RenderCreate.  This is where the AWT
> magic is happening and
> the render window is being moved to the AWT drawing
> surface.  I'm not
> experienced enough to modify this function.
> 
> Here are my questions
> 1.  Is there a class analogous to vtkPanel that
> extends something from the
> javax.swing package?
> 2.  Is this a problem someone is already working on,
> or is it on the VTK
> roadmap?
> 3.  Does the community of people using Java swing with
> VTK care about this
> (I know for me it's a big deal, but I want to make sure
> other people agree
> with me).
> 
> Thanks
> 
> 
> 
>       
> 


      



More information about the vtkusers mailing list