popupNode = (DefaultMutableTreeNode) selPath.getLastPathComponent(); Object o = popupNode.getUserObject(); if (popupNode.isRoot()) {
DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) selPath.getLastPathComponent(); Object o = selectedNode.getUserObject(); if (selectedNode.isRoot()) {
  private void doPopup(MouseEvent e) {    TreePath selPath = workspace.getPathForLocation(e.getX(), e.getY());    if (selPath == null) return;    // set the selected node to be the node the mouse is pointing at    workspace.setSelectionPath(selPath);    popupNode = (DefaultMutableTreeNode) selPath.getLastPathComponent();    Object o = popupNode.getUserObject();    if (popupNode.isRoot()) {      rootMenu.show(workspace, e.getX(), e.getY());    } else if (o instanceof SocietyComponent) {      configureSocietyMenu(((SocietyComponent)o).isEditable());      societyMenu.show(workspace, e.getX(), e.getY());    } else if (o instanceof RecipeComponent) {      configureRecipeMenu(((RecipeComponent)o).isEditable());      recipeMenu.show(workspace, e.getX(), e.getY());    } else if (o instanceof Experiment) {      configureExperimentMenu(((Experiment)o));      experimentMenu.show(workspace, e.getX(), e.getY());    } else if (o instanceof ModifiableConfigurableComponent) {      configureComponentMenu(((ModifiableConfigurableComponent)o).isEditable());      componentMenu.show(workspace, e.getX(), e.getY());    } else if (o instanceof String) {      treeMenu.show(workspace, e.getX(), e.getY());    }  }