renameComponent(node, name);
renameComponent(getSelectedNode(), name);
  private void renameComponent(DefaultMutableTreeNode node) {    ModifiableConfigurableComponent societyComponent =      (ModifiableConfigurableComponent) node.getUserObject();    if (societyComponent instanceof SocietyComponent) {      renameSociety(node);    } else if (societyComponent instanceof Experiment) {      renameExperiment(node);    } else if (societyComponent instanceof RecipeComponent) {      renameRecipe(node);    }    String name = JOptionPane.showInputDialog("New component name");    renameComponent(node, name);  }