private void deleteNodeFromTree(JTree tree) { TreePath path = tree.getSelectionPath(); if (path == null) { System.out.println("HostConfigurationBuilder deleteNodeMenuItem called with null path; ignoring"); return; }
private void deleteNodeFromTree(JTree tree, TreePath path) {
  private void deleteNodeFromTree(JTree tree) {    TreePath path = tree.getSelectionPath();    if (path == null) {      System.out.println("HostConfigurationBuilder deleteNodeMenuItem called with null path; ignoring");      return;    }    DefaultMutableTreeNode selectedNode =       (DefaultMutableTreeNode)path.getLastPathComponent();    ConsoleTreeObject nodeCTO =       (ConsoleTreeObject)selectedNode.getUserObject();    // get any agents that are descendants of the node being deleted    // and return them to the agent tree    DefaultTreeModel agentModel = (DefaultTreeModel)agentTree.getModel();    DefaultMutableTreeNode root =       (DefaultMutableTreeNode)agentModel.getRoot();    int n = selectedNode.getChildCount();    for (int i = 0; i < n; i++) {      DefaultMutableTreeNode node = 	(DefaultMutableTreeNode)selectedNode.getChildAt(0);      ConsoleTreeObject cto = (ConsoleTreeObject)node.getUserObject();      if (cto.isAgent()) { 	agentModel.insertNodeInto(node, root, root.getChildCount()); 	agentTree.scrollPathToVisible(new TreePath(node.getPath()));      }    }    DefaultTreeModel model = (DefaultTreeModel)tree.getModel();    model.removeNodeFromParent(selectedNode);    experiment.removeNode((NodeComponent)nodeCTO.getComponent());  }