if (tree.equals(hostTree)) { nodeToHost.put(nodeComponent, selectedNode.getUserObject()); }
  private void newNodeInTree(JTree tree) {    TreePath path = tree.getSelectionPath();    if (path == null) {      System.out.println("HostConfigurationBuilder newNodeInTree called with null path; ignoring");      return;    }    DefaultMutableTreeNode selectedNode =       (DefaultMutableTreeNode)path.getLastPathComponent();    String nodeName = null;    while (true) {      nodeName = JOptionPane.showInputDialog("New node name: ");      if (nodeName == null || nodeName.length() == 0)        return;      // don't allow node names that are the same as node or agent names      if (isNodeNameUnique(nodeName))        break;      int ok = JOptionPane.showConfirmDialog(this,                                             "Use an unique name",                                             "Node Name Not Unique",                                             JOptionPane.OK_CANCEL_OPTION,                                             JOptionPane.ERROR_MESSAGE);      if (ok != JOptionPane.OK_OPTION) return;    }    DefaultTreeModel model = (DefaultTreeModel)tree.getModel();    NodeComponent nodeComponent = experiment.addNode(nodeName);    DefaultMutableTreeNode newNode =      new DefaultMutableTreeNode(new ConsoleTreeObject(nodeComponent));    model.insertNodeInto(newNode,			 selectedNode,			 selectedNode.getChildCount());    tree.scrollPathToVisible(new TreePath(newNode.getPath()));  }