nodeTree.setSelectionPath(selPath); DefaultMutableTreeNode selNode = (DefaultMutableTreeNode)selPath.getLastPathComponent(); ConsoleTreeObject selected = (ConsoleTreeObject)selNode.getUserObject();  if (selected.isRoot()) nodeRootMenu.show(nodeTree, e.getX(), e.getY()); else if (selected.isNode()) nodeNodeMenu.show(nodeTree, e.getX(), e.getY());
TreePath[] selectedPaths = nodeTree.getSelectionPaths(); if (nodeTree.isPathSelected(selPath) && selectedPaths.length > 1) { boolean haveNodes = false; for (int i = 0; i < selectedPaths.length; i++) { DefaultMutableTreeNode selNode = (DefaultMutableTreeNode)selectedPaths[i].getLastPathComponent(); ConsoleTreeObject selected = (ConsoleTreeObject)selNode.getUserObject(); if (selected.isNode()) haveNodes = true; else { haveNodes = false; break; } }   if (haveNodes) { cmdLineNodeMenuItem.setEnabled(false); nodeNodeMenu.show(nodeTree, e.getX(), e.getY()); return; } } else {  nodeTree.setSelectionPath(selPath); DefaultMutableTreeNode selNode = (DefaultMutableTreeNode)selPath.getLastPathComponent(); ConsoleTreeObject selected = (ConsoleTreeObject)selNode.getUserObject();  if (selected.isRoot()) nodeRootMenu.show(nodeTree, e.getX(), e.getY()); else if (selected.isNode()) { cmdLineNodeMenuItem.setEnabled(true); nodeNodeMenu.show(nodeTree, e.getX(), e.getY()); } }
  public void displayNodeTreeMenu(MouseEvent e) {    TreePath selPath = nodeTree.getPathForLocation(e.getX(), e.getY());    if (selPath == null)      return;    // set the selected node to be the node the mouse is pointing at    nodeTree.setSelectionPath(selPath);    DefaultMutableTreeNode selNode =      (DefaultMutableTreeNode)selPath.getLastPathComponent();    ConsoleTreeObject selected =      (ConsoleTreeObject)selNode.getUserObject();    // display popup menu    if (selected.isRoot())      nodeRootMenu.show(nodeTree, e.getX(), e.getY());    else if (selected.isNode())      nodeNodeMenu.show(nodeTree, e.getX(), e.getY());  }