code: public void setControlledPanel (final JComponent panel)
      {
          panel.addHierarchyListener(new HierarchyListener() {
              public void hierarchyChanged (HierarchyEvent e) {
                  boolean nowShowing = panel.isDisplayable();
                  //System.err.println("Controller." + Controller.this +
                  //    "  nowShowing=" + nowShowing +
                  //    ", wasShowing=" + _showing);
                  if (_showing != nowShowing) {
                      _showing = nowShowing;
                      if (_showing) {
                          wasAdded();
                      } else {
                          wasRemoved();
                      }
                  }
              }
  
              boolean _showing = false;
          });
      }
docs: Lets this controller know about the panel that it is controlling.