newHostMenuItem.setEnabled(isHostRootSelected);
      public void menuSelected(MenuEvent e) {        Component selectedComponent = tabbedPane.getSelectedComponent();        boolean communityEnabled = selectedComponent.equals(communityPanel);        newCommunityMenuItem.setEnabled(communityEnabled);        viewCommunityMenuItem.setEnabled(communityEnabled);        boolean hcbEnabled = selectedComponent.equals(hcb);        globalCommandLineMenuItem.setEnabled(hcbEnabled);        newHostMenuItem.setEnabled(hcbEnabled);        newNodeMenu.setEnabled(hcbEnabled);        commandLineMenuItem.setEnabled(hcbEnabled);        describeHostMenuItem.setEnabled(hcbEnabled);        describeNodeMenuItem.setEnabled(hcbEnabled);        hostTypeMenuItem.setEnabled(hcbEnabled);        hostLocationMenuItem.setEnabled(hcbEnabled);        deleteHostMenuItem.setEnabled(hcbEnabled);        deleteNodeMenuItem.setEnabled(hcbEnabled);        if (!hcbEnabled)          return;        // configure menu items for host configuration builder        // enable "global command line" command         // if either root, or any set of hosts or nodes is selected        DefaultMutableTreeNode[] hostsInHostTree =           hcb.getSelectedHostsInHostTree();        DefaultMutableTreeNode[] nodesInHostTree =           hcb.getSelectedNodesInHostTree();        DefaultMutableTreeNode[] nodesInNodeTree =           hcb.getSelectedNodesInNodeTree();        boolean isHostRootSelected = hcb.isHostTreeRootSelected();        boolean isNodeRootSelected = hcb.isNodeTreeRootSelected();        newHostMenuItem.setEnabled(isHostRootSelected);        if (isHostRootSelected || isNodeRootSelected ||            (hostsInHostTree != null) ||            (nodesInHostTree != null) ||            (nodesInNodeTree != null))          globalCommandLineMenuItem.setEnabled(true);        else          globalCommandLineMenuItem.setEnabled(false);        // enable "new node" command if unassigned nodes root is selected        // or one host is selected in the host tree        newUnassignedNodeMenuItem.setEnabled(isNodeRootSelected);        if (hostsInHostTree != null && hostsInHostTree.length == 1) {          newAssignedNodeMenuItem.setText("On " +                                           hostsInHostTree[0].toString());          newAssignedNodeMenuItem.setEnabled(true);        } else           newAssignedNodeMenuItem.setEnabled(false);        newNodeMenu.setEnabled(newAssignedNodeMenuItem.isEnabled() ||                               newUnassignedNodeMenuItem.isEnabled());        // enable "new host" command if host tree root is selected        newHostMenuItem.setEnabled(isHostRootSelected);        // if a single node is selected        // enable "command line arguments"        int nodeCount = 0;        if (nodesInHostTree != null)          nodeCount = nodesInHostTree.length;        if (nodesInNodeTree != null)          nodeCount += nodesInNodeTree.length;        commandLineMenuItem.setEnabled(nodeCount == 1);        describeHostMenuItem.setEnabled(hostsInHostTree != null);        describeNodeMenuItem.setEnabled(nodesInHostTree != null ||                                        nodesInNodeTree != null);        hostTypeMenuItem.setEnabled(hostsInHostTree != null);        hostLocationMenuItem.setEnabled(hostsInHostTree != null);        deleteHostMenuItem.setEnabled(hostsInHostTree != null);        deleteNodeMenuItem.setEnabled(nodesInHostTree != null ||                                      nodesInNodeTree != null);      }