// must be called on AWT event thread
  private void setWindowVisible(boolean visible) {
    if (visible) {
      if (entity != null) {
        throw new IllegalStateException("Entity already created");
      }

      // create the image
      Canvas canvas = JmeClientMain.getFrame().getCanvas();

      synchronized (this) {
        entity = new StereoViewEntity(canvas.getWidth(), canvas.getHeight());
        frame = new StereoViewFrame(createImage(entity, canvas.getWidth(), canvas.getHeight()));
      }

      entity.setDistance(getDistance());
      entity.setAngle(getAngle());
      entity.setEnabled(true);

      frame.addWindowListener(
          new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
              LOGGER.warning("Stereo window closing");

              // uncheck the checkbox, which should also dispose of
              // the frame
              if (stereoMI != null) {
                stereoMI.setSelected(false);
              }

              if (entity != null) {
                setWindowVisible(false);
              }
            }
          });

      frame.setSize(JmeClientMain.getFrame().getFrame().getSize());
      frame.setVisible(true);
    } else {
      if (entity == null) {
        // already disposed
        return;
      }

      frame.dispose();
      entity.dispose();

      synchronized (this) {
        frame = null;
        entity = null;
      }
    }
  }
 public void unregister() {
   // deactivate
   JmeClientMain.getFrame().removeFromToolsMenu(cellViewerMI);
   JmeClientMain.getFrame().removeFromFileMenu(createModuleMI);
 }
 public void register() {
   // activate
   System.err.println("********* HERE !!!!!");
   JmeClientMain.getFrame().addToToolsMenu(cellViewerMI, 7);
   JmeClientMain.getFrame().addToFileMenu(createModuleMI, 1);
 }