experiment.removeExperimentListener(listener);
if (experiment != null) experiment.removeExperimentListener(listener);
  public void actionPerformed(ActionEvent e) {    String s = ((AbstractButton)e.getSource()).getActionCommand();    if (s.equals(NamedFrame.COMMUNITY)) {      makeCommunityGraph();    } else if (s.equals(NamedFrame.AGENT)) {      makeSocietyGraph(); // only the name changes!    } else if (s.equals(NamedFrame.PLAN)) {      makePlanGraph();    } else if (s.equals(NamedFrame.THREAD)) {      makeThreadGraph();    } else if (s.equals(NamedFrame.METRICS)) {      makeMetricsGraph();    } else if (s.equals(OPEN_GRAPH_MENU_ITEM)) {      openGraph();    } else if (s.equals(OPEN_METRIC_MENU_ITEM)) {      openMetrics();    } else if (s.equals(MONITOR_MENU_ITEM)) {      getAgentURL();    } else if (s.equals(EXIT_MENU_ITEM)) {      if (csmart == null)	System.exit(0); // if running standalone, exit      else {	closeSubWindows();	experiment.removeExperimentListener(listener);	NamedFrame.getNamedFrame().removeFrame(this);	dispose();      }    } else if (s.equals(HELP_MENU_ITEM)) {      URL help = (URL)getClass().getResource(HELP_DOC);      if (help != null)	Browser.setPage(help);    } else if (s.equals(ABOUT_CSMART_ITEM)) {      URL about = (URL)getClass().getResource(ABOUT_DOC);      if (about != null)	Browser.setPage(about);    } else {      JFrame f = NamedFrame.getNamedFrame().getFrame(s);      if (f != null) {	f.toFront();	f.setState(Frame.NORMAL);      }      }  }