hostTree.setSelectionPath(selPath); DefaultMutableTreeNode selNode = (DefaultMutableTreeNode)selPath.getLastPathComponent(); ConsoleTreeObject selected = (ConsoleTreeObject)selNode.getUserObject();  if (selected.isRoot()) hostRootMenu.show(hostTree, e.getX(), e.getY()); else if (selected.isHost()) hostHostMenu.show(hostTree, e.getX(), e.getY()); else if (selected.isNode()) hostNodeMenu.show(hostTree, e.getX(), e.getY());
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 {  hostTree.setSelectionPath(selPath); DefaultMutableTreeNode selNode = (DefaultMutableTreeNode)selPath.getLastPathComponent(); ConsoleTreeObject selected = (ConsoleTreeObject)selNode.getUserObject();  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()); } }
  public void displayHostTreeMenu(MouseEvent e) {    TreePath selPath = hostTree.getPathForLocation(e.getX(), e.getY());    if (selPath == null)      return;    // 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())      hostHostMenu.show(hostTree, e.getX(), e.getY());    else if (selected.isNode())      hostNodeMenu.show(hostTree, e.getX(), e.getY());  } 