DefaultMutableTreeNode node = getSelectedNode(); SocietyComponent societyComponent = (SocietyComponent) node.getUserObject(); if (newName.equals(societyComponent.getSocietyName()))
if (newName.equals(originalName))
  public void renameSociety() {    String newName = getUniqueName("New society name",                                   "Society Name Not Unique",                                   societyNames);    if (newName == null)      return;    DefaultMutableTreeNode node = getSelectedNode();    SocietyComponent societyComponent =       (SocietyComponent) node.getUserObject();    if (newName.equals(societyComponent.getSocietyName()))      return;    societyNames.remove(societyComponent.getSocietyName());    societyNames.add(newName);    societyComponent.setName(newName);    model.nodeChanged(node);  }