exit();
if(!CSMART.this.getGlassPane().isVisible()) { exit(); }
  public CSMART() {    setTitle("CSMART");    createLog();    // Write initial CSMART info to the log file    if (log.isShoutEnabled()) {      log.shout(writeDebug());    }    resultDir = initResultDir();    organizer = new Organizer(this);    JMenuBar menuBar = new JMenuBar();    getRootPane().setJMenuBar(menuBar);    // set-up file menu which includes entries based on workspace selection    fileMenu = new JMenu(FILE_MENU);    fileMenu.setToolTipText("Create new workspace or quit.");    fileMenu.addMenuListener(myMenuListener);    JMenuItem newMenuItem = new JMenuItem(NEW_MENU_ITEM);    newMenuItem.addActionListener(new ActionListener() {        public void actionPerformed(ActionEvent e) {          newWorkspace();        }      });    newMenuItem.setToolTipText("Create a new workspace.");    fileMenu.add(newMenuItem);    JMenuItem newResultsMenuItem = new JMenuItem(NEW_RESULTS_MENU_ITEM);    newResultsMenuItem.addActionListener(new ActionListener() {        public void actionPerformed(ActionEvent e) {          setResultDir();        }      });    newResultsMenuItem.setToolTipText("Select a directory for saving results");    fileMenu.add(newResultsMenuItem);    JMenu newExperimentMenu = new JMenu(ActionUtil.NEW_EXPERIMENT_ACTION);    for (int i = 0; i < organizer.newExperimentActions.length; i++)      newExperimentMenu.add(organizer.newExperimentActions[i]);    fileMenu.add(newExperimentMenu);    JMenu newRecipeMenu = new JMenu(ActionUtil.NEW_RECIPE_ACTION);    for (int i = 0; i < organizer.newRecipeActions.length; i++)      newRecipeMenu.add(organizer.newRecipeActions[i]);    fileMenu.add(newRecipeMenu);    fileMenu.add(new JMenuItem(organizer.newFolderAction));    fileMenu.addSeparator();    fileMenu.add(new JMenuItem(organizer.configureAction));    fileMenu.add(new JMenuItem(organizer.buildExperimentAction));    fileMenu.add(new JMenuItem(organizer.runExperimentAction));    fileMenu.add(new JMenuItem(organizer.duplicateAction));    fileMenu.add(new JMenuItem(organizer.deleteAction));    fileMenu.add(new JMenuItem(organizer.deleteExperimentFromDatabaseAction));    fileMenu.add(new JMenuItem(organizer.deleteRecipeFromDatabaseAction));    fileMenu.add(new JMenuItem(organizer.renameAction));    fileMenu.addSeparator();    JMenuItem exitMenuItem = new JMenuItem(EXIT_MENU_ITEM);    exitMenuItem.addActionListener(new ActionListener() {        public void actionPerformed(ActionEvent e) {          exit();        }      });    exitMenuItem.setToolTipText("Exit");    fileMenu.add(exitMenuItem);    windowMenu = new JMenu(WINDOW_MENU);    windowMenu.setToolTipText("Display selected window.");    JMenu helpMenu = new JMenu(HELP_MENU);    for (int i = 0; i < helpActions.length; i++)       helpMenu.add(new JMenuItem(helpActions[i]));    menuBar.add(fileMenu);    menuBar.add(windowMenu);    menuBar.add(helpMenu);    toolBar = new JToolBar();    toolBar.setLayout(new GridLayout(1, 5, 2, 2));    getContentPane().add("North", toolBar);    organizer.addTreeSelectionListener(new TreeSelectionListener() {        public void valueChanged(TreeSelectionEvent e) {          enableCSMARTTools();        }      });    getContentPane().add("Center", organizer);    Action societyAction = new AbstractAction() {        public void actionPerformed(ActionEvent e) {          JFrame societyMonitorFrame =             NamedFrame.getNamedFrame().getToolFrame(SOCIETY_MONITOR);          if (societyMonitorFrame == null)            runMonitor();          else            societyMonitorFrame.toFront();        }      };    Action analyzerAction = new AbstractAction() {        public void actionPerformed(ActionEvent e) {          DefaultMutableTreeNode node = organizer.getSelectedNode();          Object userObject = node.getUserObject();          if (userObject instanceof Experiment)            runAnalyzer((Experiment)userObject);          else            runAnalyzer();        }      };    Action[] actions = {      organizer.configureAction,      organizer.buildExperimentAction,      organizer.runExperimentAction,      societyAction,      analyzerAction    };    for (int i = 0; i < views.length; i++) {      JButton button = makeButton(views[i], iconFilenames[i],                                   actions[i]);      button.setHorizontalTextPosition(JButton.CENTER);      button.setVerticalTextPosition(JButton.BOTTOM);      button.setActionCommand(views[i]);      button.setToolTipText(tooltips[i]);      toolBar.add(button);    }    configureButton = (JButton)toolBar.getComponentAtIndex(0);    buildButton = (JButton)toolBar.getComponentAtIndex(1);    runButton = (JButton)toolBar.getComponentAtIndex(2);    enableCSMARTTools();    // if user closes this window, quit    addWindowListener(new WindowAdapter() {      public void windowClosing(WindowEvent e) {	exit();      }    });    NamedFrame.getNamedFrame().addObserver(myFrameObserver);    pack();    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();    int w = getWidth();    int h = getHeight();    setSize(w, h);    setLocation((screenSize.width - w)/2, (screenSize.height - h)/2);    setVisible(true);  }