else
} else
  protected void deleteFolder() {    DefaultMutableTreeNode node = getSelectedNode();    if (node == root) return;    if (node == null) return;    int reply =       JOptionPane.showConfirmDialog(this,                                    "Delete folder and all its contents?",                                    "Delete Folder",                                    JOptionPane.OK_CANCEL_OPTION,                                    JOptionPane.PLAIN_MESSAGE);    if (reply != JOptionPane.OK_OPTION)      return;    // if this folder is empty, just delete it    if (node.isLeaf()) {      model.removeNodeFromParent(node);      return;    }    // make a list of nodes to delete    // because we can't delete nodes while traversing the tree    ArrayList nodesToDelete = new ArrayList();    Enumeration nodes = node.breadthFirstEnumeration();    nodes.nextElement(); // skip the first node which is this node    while (nodes.hasMoreElements()) {      DefaultMutableTreeNode childNode =        (DefaultMutableTreeNode)nodes.nextElement();      nodesToDelete.add(childNode);    }    // delete the leaf nodes and user objects    for (int i = 0; i < nodesToDelete.size(); i++) {      DefaultMutableTreeNode nodeToDelete =        (DefaultMutableTreeNode)nodesToDelete.get(i);      Object o = nodeToDelete.getUserObject();      if (o instanceof Experiment)        deleteExperimentInNode(nodeToDelete);      else if (o instanceof SocietyComponent)        deleteSocietyInNode(nodeToDelete);      else if (o instanceof RecipeComponent)        deleteRecipeInNode(nodeToDelete);      else if (o instanceof String) // an empty folder        model.removeNodeFromParent(nodeToDelete); // just delete the tree node    }    // now we're left with the components the user decided not to delete    // and the folder(s) containing them, but we need to    // recursively delete the folder(s) that are empty or contain only    // empty folders    if (node.isLeaf())      model.removeNodeFromParent(node);    else      deleteEmptyFolders(node);  }