DefaultMutableTreeNode node = findNodeNamed(recipeName); if (node != null) { workspace.setSelection(node); model.removeNodeFromParent(node); recipeNames.remove(recipeName); }
  public void deleteRecipeFromDatabase() {    Map recipeNamesHT = helper.getRecipeNamesFromDatabase();    Set dbRecipeNames = recipeNamesHT.keySet();    if (dbRecipeNames.isEmpty()) {      JOptionPane.showMessageDialog(this,                                    "There are no recipes in the database",                                    "No Database Recipes",                                    JOptionPane.INFORMATION_MESSAGE);      return;    }    JComboBox cb = new JComboBox(dbRecipeNames.toArray());    cb.setEditable(false);    JPanel panel = new JPanel();    panel.add(new JLabel("Delete Recipe:"));    panel.add(cb);    int result =       JOptionPane.showConfirmDialog(null, panel, "Delete Recipe",                                    JOptionPane.OK_CANCEL_OPTION,                                    JOptionPane.PLAIN_MESSAGE);    if (result != JOptionPane.OK_OPTION)      return;    String recipeName = (String)cb.getSelectedItem();    try {      helper.deleteRecipe(recipeName);    } catch (Exception e) {      JOptionPane.showMessageDialog(this,                                    "An exception occurred deleting the recipe from the database",                                    "Error Writing Database",                                    JOptionPane.ERROR_MESSAGE);    }  }