[vtkusers] VisibilityOff() hangs Java
Jeff Lee
jeff at cdnorthamerica.com
Thu Sep 2 07:38:58 EDT 2004
Hi Chris,
It is because vtkPanel will not render when the number of visible actors
is zero. The app isn't really hanging. Try putting two actors in and
setting one invisible and it will work as expected. Arguably a bug when
there is just one actor, but vtkPanel is only an example. Let me know
if you have more questions...
-Jeff
Christopher.Moore at noaa.gov wrote:
>Calling vtkActor.VisibilityOff() in Java hangs the application. Am I
>doing something silly?
>
>I modified the Java Wrapper example by making the coneActor global, and
>changing the "Exit" button to simply call coneActor.VisibilityOff()
>
>Thanks,
>Chris
>
>__________________________________________________________________
>Christopher Moore email: Christopher.Moore at noaa.gov
>Research Scientist, Oceanography tel: 206.526.6779
>University of Washington/JISAO/NOAA-PMEL fax: 206.526.6744
>------------------------------------------------------------------
>
>
>import java.awt.*;
>import java.awt.event.*;
>import javax.swing.*;
>import vtk.*;
>
>/**
> * An application that displays a JButton.
> */
>public class SimpleVTK extends JPanel implements ActionListener {
> static JFrame frame;
> vtkPanel renWin;
> vtkActor coneActor;
> JButton exitButton;
>
> public SimpleVTK() {
> setLayout(new BorderLayout());
> // Create the buttons.
> renWin = new vtkPanel();
> vtkConeSource cone = new vtkConeSource();
> cone.SetResolution(8);
> vtkPolyDataMapper coneMapper = new vtkPolyDataMapper();
> coneMapper.SetInput(cone.GetOutput());
>
> coneActor = new vtkActor();
> coneActor.SetMapper(coneMapper);
>
> renWin.GetRenderer().AddActor(coneActor);
>
> exitButton = new JButton("Invisible");
> exitButton.addActionListener(this);
>
> add(renWin, BorderLayout.CENTER);
> add(exitButton, BorderLayout.EAST);
> }
>
>
> /** An ActionListener that listens to the radio buttons. */
> public void actionPerformed(ActionEvent e)
> {
> if (e.getSource().equals(exitButton))
> {
> // System.exit(0);
> coneActor.VisibilityOff();
> }
> }
>
> public static void main(String s[])
> {
> SimpleVTK panel = new SimpleVTK();
>
> frame = new JFrame("SimpleVTK");
> frame.addWindowListener(new WindowAdapter()
> {
> public void windowClosing(WindowEvent e) {System.exit(0);}
> });
> frame.getContentPane().add("Center", panel);
> frame.pack();
> frame.setVisible(true);
> }
>}
>
>
>
>_______________________________________________
>This is the private VTK discussion list.
>Please keep messages on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
>Follow this link to subscribe/unsubscribe:
>http://www.vtk.org/mailman/listinfo/vtkusers
>
>
>
>
More information about the vtkusers
mailing list