[vtkusers] VisibilityOff() hangs Java

Christopher.Moore at noaa.gov Christopher.Moore at noaa.gov
Wed Sep 1 23:23:23 EDT 2004


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);
  }
}






More information about the vtkusers mailing list