hostNodeMenu.show(hostTree, e.getX(), e.getY());
if (hostTree.isEditable()) hostNodeMenu.show(hostTree, e.getX(), e.getY()); else viewOnlyMenu.show(hostTree, e.getX(), e.getY());
  private void displayHostTreeMenu(MouseEvent e) {    // the path to the node the mouse is pointing at    TreePath selPath = hostTree.getPathForLocation(e.getX(), e.getY());    if (selPath == null)      return;    // if the mouse is pointing at a selected node    // and all selected nodes are of the same type, then act on all of them    TreePath[] selectedPaths = hostTree.getSelectionPaths();    if (hostTree.isPathSelected(selPath) && selectedPaths.length > 1) {      boolean haveHosts = false;      boolean haveNodes = false;      for (int i = 0; i < selectedPaths.length; i++) {        DefaultMutableTreeNode selNode =          (DefaultMutableTreeNode)selectedPaths[i].getLastPathComponent();        ConsoleTreeObject selected =          (ConsoleTreeObject)selNode.getUserObject();        if (selected.isHost()) {          if (!haveHosts && !haveNodes)            haveHosts = true;          else if (haveNodes) {            haveNodes = false;            break;          }        } else if (selected.isNode()) {          if (!haveHosts && !haveNodes)            haveNodes = true;          else if (haveHosts) {            haveHosts = false;            break;          }        } else {          haveHosts = false;          haveNodes = false;          break;        }      }      if (haveHosts) {        newNodeInHostMenuItem.setEnabled(false);        hostHostMenu.show(hostTree, e.getX(), e.getY());        return;      } else if (haveNodes) {        cmdLineNodeInHostMenuItem.setEnabled(false);        hostNodeMenu.show(hostTree, e.getX(), e.getY());        return;      }    } else {      // else set the selected node to be the node the mouse is pointing at      hostTree.setSelectionPath(selPath);      DefaultMutableTreeNode selNode =        (DefaultMutableTreeNode)selPath.getLastPathComponent();      ConsoleTreeObject selected =        (ConsoleTreeObject)selNode.getUserObject();      // display popup menu       if (selected.isRoot())        hostRootMenu.show(hostTree, e.getX(), e.getY());      else if (selected.isHost()) {        newNodeInHostMenuItem.setEnabled(true);        hostHostMenu.show(hostTree, e.getX(), e.getY());      } else if (selected.isNode()) {        cmdLineNodeInHostMenuItem.setEnabled(true);        hostNodeMenu.show(hostTree, e.getX(), e.getY());      }     }  } 