List of usage examples for javax.swing.tree DefaultMutableTreeNode isLeaf
public boolean isLeaf()
From source file:com.emental.mindraider.ui.outline.OutlineJPanel.java
/** * Discard concept.//from w w w . j a v a2 s .c o m */ public void conceptDiscard() { if (MindRaider.profile.getActiveOutlineUri() == null) { JOptionPane.showMessageDialog(OutlineJPanel.this, Messages.getString("NotebookOutlineJPanel.toDiscardConceptTheNotebookMustBeOpened"), Messages.getString("NotebookOutlineJPanel.discardConceptError"), JOptionPane.ERROR_MESSAGE); return; } // move concept up in the tree DefaultMutableTreeNode node = getSelectedTreeNode(); if (node != null) { if (node.isLeaf() && node.getParent() != null) { try { if (JOptionPane.showConfirmDialog(MindRaider.mainJFrame, Messages.getString("NotebookOutlineJPanel.doYouWantToDiscardConcept", node.toString()), Messages.getString("NotebookOutlineJPanel.discardConcept"), JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION) { return; } DefaultMutableTreeNode parent = (DefaultMutableTreeNode) node.getParent(); String notebookUri = MindRaider.outlineCustodian.getActiveOutlineResource().resource .getMetadata().getUri().toString(); MindRaider.noteCustodian.discard(notebookUri, ((OutlineNode) parent).getUri(), ((OutlineNode) node).getUri()); refresh(); MindRaider.spidersGraph.selectNodeByUri(notebookUri); MindRaider.spidersGraph.renderModel(); conceptJPanel.clear(); } catch (Exception e1) { logger.debug(Messages.getString("NotebookOutlineJPanel.unableToDiscardConcept"), e1); StatusBar.show(Messages.getString("NotebookOutlineJPanel.unableToDiscardConcept")); } } else { StatusBar.show(Messages.getString("NotebookOutlineJPanel.discardingOnlyLeafConcepts")); JOptionPane.showMessageDialog(OutlineJPanel.this, Messages.getString("NotebookOutlineJPanel.discardingOnlyLeafConcepts"), "Concept Discard Error", JOptionPane.ERROR_MESSAGE); return; } } else { logger.debug(Messages.getString("NotebookOutlineJPanel.noNodeSelected")); } }
From source file:com.emental.mindraider.ui.outline.OutlineJPanel.java
public void conceptRefactor() { String sourceOutlineUri;/* www . j a v a2 s .co m*/ String sourceConceptUri; if (MindRaider.profile.getActiveOutlineUri() == null) { JOptionPane.showMessageDialog(OutlineJPanel.this, Messages.getString("NotebookOutlineJPanel.toRefactorConceptTheNotebookMustBeOpened"), Messages.getString("NotebookOutlineJPanel.refactoringError"), JOptionPane.ERROR_MESSAGE); return; } DefaultMutableTreeNode node = getSelectedTreeNode(); if (node != null) { if (node.isLeaf()) { try { if (JOptionPane.showConfirmDialog(MindRaider.mainJFrame, Messages.getString("NotebookOutlineJPanel.doYouWantToRefactorConcept", node.toString()), Messages.getString("NotebookOutlineJPanel.refactorConcept"), JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION) { return; } DefaultMutableTreeNode parent = (DefaultMutableTreeNode) node.getParent(); sourceOutlineUri = MindRaider.outlineCustodian.getActiveOutlineResource().resource.getMetadata() .getUri().toString(); sourceConceptUri = ((OutlineNode) node).getUri(); MindRaider.noteCustodian.discard(sourceOutlineUri, ((OutlineNode) parent).getUri(), sourceConceptUri); ConceptResource conceptResource = MindRaider.noteCustodian.get(sourceOutlineUri, sourceConceptUri); // choose target outline and create new concept into this notebook new OpenOutlineJDialog(Messages.getString("NotebookOutlineJPanel.refactorConcept"), Messages.getString("NotebookOutlineJPanel.selectTargetNotebook"), Messages.getString("NotebookOutlineJPanel.refactor"), false); // create that concept in the target notebook (put it to the root) String targetConceptUri = conceptResource.resource.getMetadata().getUri().toString(); while (MindRaiderConstants.EXISTS.equals( MindRaider.noteCustodian.create(MindRaider.outlineCustodian.getActiveOutlineResource(), null, conceptResource.getLabel(), targetConceptUri, conceptResource.getAnnotation(), false))) { targetConceptUri += "_"; } // refactor also attachments AttachmentProperty[] attachments = conceptResource.getAttachments(); if (!ArrayUtils.isEmpty(attachments)) { ConceptResource newConceptResource = MindRaider.noteCustodian .get(MindRaider.outlineCustodian.getActiveOutlineResource().resource.getMetadata() .getUri().toString(), targetConceptUri); for (AttachmentProperty attachment : attachments) { newConceptResource.addAttachment(attachment.getDescription(), attachment.getUrl()); } newConceptResource.save(); } // delete discarded concept in the source outline MindRaider.noteCustodian.deleteConcept(sourceOutlineUri, sourceConceptUri); refresh(); MindRaider.spidersGraph.selectNodeByUri(sourceOutlineUri); MindRaider.spidersGraph.renderModel(); } catch (Exception e1) { logger.debug(Messages.getString("NotebookOutlineJPanel.unableToRefactorConcept"), e1); StatusBar.show(Messages.getString("NotebookOutlineJPanel.unableToRefactorConcept")); } } else { StatusBar.show(Messages.getString("NotebookOutlineJPanel.discardingingOnlyLeafConcepts")); JOptionPane.showMessageDialog(OutlineJPanel.this, Messages.getString("NotebookOutlineJPanel.refactoringOnlyLeafConcepts"), Messages.getString("NotebookOutlineJPanel.refactoringError"), JOptionPane.ERROR_MESSAGE); return; } } else { logger.debug(Messages.getString("NotebookOutlineJPanel.noNodeSelected")); } }
From source file:base.BasePlayer.AddGenome.java
public AddGenome() { super(new BorderLayout()); makeGenomes();/*from w ww . j a v a 2s . c om*/ tree = new JTree(root); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION); sizeError.setForeground(Draw.redColor); sizeError.setVisible(true); treemodel = (DefaultTreeModel) tree.getModel(); remscroll = new JScrollPane(remtable); tree.setCellRenderer(new DefaultTreeCellRenderer() { private static final long serialVersionUID = 1L; private Icon collapsedIcon = UIManager.getIcon("Tree.collapsedIcon"); private Icon expandedIcon = UIManager.getIcon("Tree.expandedIcon"); // private Icon leafIcon = UIManager.getIcon("Tree.leafIcon"); private Icon addIcon = UIManager.getIcon("Tree.closedIcon"); // private Icon saveIcon = UIManager.getIcon("OptionPane.informationIcon"); @Override public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean isLeaf, int row, boolean focused) { Component c = super.getTreeCellRendererComponent(tree, value, selected, expanded, isLeaf, row, focused); if (!isLeaf) { //setFont(getFont().deriveFont(Font.PLAIN)); if (expanded) { setIcon(expandedIcon); } else { setIcon(collapsedIcon); } /* if(((DefaultMutableTreeNode) value).getUserObject().toString().equals("Annotations")) { this.setFocusable(false); setFont(getFont().deriveFont(Font.BOLD)); setIcon(null); } */ } else { if (((DefaultMutableTreeNode) value).getUserObject().toString().equals("Annotations")) { // setFont(getFont().deriveFont(Font.PLAIN)); setIcon(null); } else if (((DefaultMutableTreeNode) value).getUserObject().toString().startsWith("Add new")) { // setFont(getFont().deriveFont(Font.PLAIN)); setIcon(addIcon); } else { // setFont(getFont().deriveFont(Font.ITALIC)); setIcon(null); // setIcon(leafIcon); } } return c; } }); tree.addMouseListener(this); tree.addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { try { DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); if (node == null) return; selectedNode = node; if (node.isLeaf()) { checkUpdates.setEnabled(false); } else { checkUpdates.setEnabled(true); } if (node.toString().startsWith("Add new") || node.toString().equals("Annotations")) { remove.setEnabled(false); } else { remove.setEnabled(true); } genometable.clearSelection(); download.setEnabled(false); } catch (Exception ex) { ex.printStackTrace(); } } }); tree.setToggleClickCount(1); tree.setRootVisible(false); treescroll = new JScrollPane(tree); checkGenomes(); genomeFileText = new JLabel("Select reference fasta-file"); annotationFileText = new JLabel("Select annotation gff3-file"); genomeName = new JTextField("Give name of the genome"); openRef = new JButton("Browse"); openAnno = new JButton("Browse"); add = new JButton("Add"); download = new JButton("Download"); checkEnsembl = new JButton("Ensembl fetch"); checkEnsembl.setMinimumSize(Main.buttonDimension); checkEnsembl.addActionListener(this); getLinks = new JButton("Get file links."); remove = new JButton("Remove"); checkUpdates = new JButton("Check updates"); download.setEnabled(false); getLinks.setEnabled(false); getLinks.addActionListener(this); remove.setEnabled(false); download.addActionListener(this); remove.addActionListener(this); panel.setBackground(Draw.sidecolor); checkUpdates.addActionListener(this); this.setBackground(Draw.sidecolor); frame.getContentPane().setBackground(Draw.sidecolor); GridBagConstraints c = new GridBagConstraints(); c.gridx = 0; c.gridy = 0; c.insets = new Insets(2, 4, 2, 4); c.gridwidth = 2; genometable.setSelectionMode(0); genometable.setShowGrid(false); remtable.setSelectionMode(0); remtable.setShowGrid(false); JScrollPane scroll = new JScrollPane(); scroll.getViewport().setBackground(Color.white); scroll.getViewport().add(genometable); remscroll.getViewport().setBackground(Color.white); genometable.addMouseListener(this); remtable.addMouseListener(this); // panel.add(welcomeLabel,c); // c.gridy++; c.anchor = GridBagConstraints.NORTHWEST; panel.add(new JLabel("Download genome reference and annotation"), c); c.gridx++; c.anchor = GridBagConstraints.NORTHEAST; panel.add(checkEnsembl, c); c.anchor = GridBagConstraints.NORTHWEST; c.weightx = 1; c.weighty = 1; c.fill = GridBagConstraints.BOTH; c.gridx = 0; c.gridy++; //c.fill = GridBagConstraints.NONE; panel.add(scroll, c); c.gridy++; c.fill = GridBagConstraints.NONE; panel.add(download, c); c.gridx = 1; panel.add(sizeError, c); c.gridx = 1; panel.add(getLinks, c); c.gridy++; c.gridx = 0; c.fill = GridBagConstraints.BOTH; panel.add(new JLabel("Add/Remove installed genomes manually"), c); c.gridy++; panel.add(treescroll, c); c.gridy++; c.fill = GridBagConstraints.NONE; c.gridwidth = 1; remove.setMinimumSize(Main.buttonDimension); panel.add(remove, c); c.gridx = 1; panel.add(checkUpdates, c); checkUpdates.setMinimumSize(Main.buttonDimension); checkUpdates.setEnabled(false); c.gridwidth = 2; c.gridx = 0; c.gridy++; try { if (Main.genomeDir != null) { genomedirectory.setText(Main.genomeDir.getCanonicalPath()); } genomedirectory.setEditable(false); genomedirectory.setBackground(Color.white); genomedirectory.setForeground(Color.black); } catch (IOException e1) { e1.printStackTrace(); } panel.add(new JLabel("Genome directory:"), c); c.gridy++; panel.add(genomedirectory, c); /* c.fill = GridBagConstraints.BOTH; c.gridy++; panel.add(new JLabel("Add genome manually"),c); c.gridy++; c.gridwidth = 2; panel.add(new JSeparator(),c); c.gridwidth = 1; c.gridy++; panel.add(genomeFileText, c); c.fill = GridBagConstraints.NONE; c.gridx = 1; panel.add(openRef, c); c.gridx = 0; openRef.addActionListener(this); c.gridy++; panel.add(annotationFileText,c); c.gridx=1; panel.add(openAnno, c); c.gridy++; panel.add(add,c); openAnno.addActionListener(this); add.addActionListener(this); add.setEnabled(false); */ add(panel, BorderLayout.NORTH); if (Main.drawCanvas != null) { setFonts(Main.menuFont); } /* html.append("<a href=http:Homo_sapiens_GRCh37:Ensembl_genes> Homo sapiens GRCh37 with Ensembl</a> or <a href=http:Homo_sapiens_GRCh37:RefSeq_genes>RefSeq</a> gene annotations<br>"); html.append("<a href=http:Homo_sapiens_GRCh38:Ensembl_genes> Homo sapiens GRCh38 with Ensembl</a> or <a href=http:Homo_sapiens_GRCh38:RefSeq_genes>RefSeq</a> gene annotations<br><br>"); html.append("<a href=http:Mus_musculus_GRCm38:Ensembl_genes> Mus musculus GRCm38 with Ensembl</a> or <a href=http:Mus_musculus_GRCm38:RefSeq_genes>RefSeq</a> gene annotations<br>"); html.append("<a href=http:Rattus_norvegicus:Ensembl_genes> Rattus norvegicus with Ensembl gene annotations</a><br>"); html.append("<a href=http:Saccharomyces_cerevisiae:Ensembl_genes> Saccharomyces cerevisiae with Ensembl gene annotation</a><br>"); html.append("<a href=http:Ciona_intestinalis:Ensembl_genes> Ciona intestinalis with Ensembl gene annotation</a><br>"); Object[] row = {"Homo_sapiens_GRCh37"}; Object[] row = {"Homo_sapiens_GRCh38"}; model.addRow(row); /* genomeName.setPreferredSize(new Dimension(300,20)); this.add(genomeName); this.add(new JSeparator()); this.add(openRef); openRef.addActionListener(this); this.add(genomeFileText); this.add(openAnno); openAnno.addActionListener(this); this.add(annotationFileText); this.add(add); add.addActionListener(this); if(annotation) { openRef.setVisible(false); genomeFileText.setVisible(false); genomeName.setEditable(false); } genomeFileText.setEditable(false); annotationFileText.setEditable(false);*/ }
From source file:GUI.MainWindow.java
/** * The vulnTree has had a selection event fire. This will find the last * selected node and display that on the right pane. It will also update the * count of selected node label at the bottom if more than one has been * selected./*from w w w . jav a 2s. c o m*/ * * @param evt */ private void VulnTreeValueChanged(javax.swing.event.TreeSelectionEvent evt) {//GEN-FIRST:event_VulnTreeValueChanged DefaultMutableTreeNode node = (DefaultMutableTreeNode) this.VulnTree.getLastSelectedPathComponent(); if (node == null) { return; } Object obj = node.getUserObject(); if (node.isLeaf() && obj instanceof Vulnerability) { // this is a vulnerability we should update the UI to show the contents showVulnerability((Vulnerability) obj); } int number_of_nodes = this.VulnTree.getSelectionCount(); this.ExtraInfoLabel.setText("Number of nodes selected: " + number_of_nodes); }
From source file:com.lp.client.frame.component.PanelDokumentenablage.java
public void valueChanged(TreeSelectionEvent arg0) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); if (tree.getPathBounds(arg0.getPath()) != null) tree.scrollRectToVisible(tree.getPathBounds(arg0.getPath())); jcrDocDto = null;//from w w w .j a v a 2 s. c o m file = null; clearComponents(); enableAllComponents(this, false); wcbVersteckteAnzeigen.setEnabled(true); wtfSuche.setEditable(true); wbuSuche.setEnabled(true); wmcMedia.setMimeType(null); if (node != null) { enableToolsPanelButtons(false, PanelBasis.ACTION_SAVE, PanelBasis.ACTION_DISCARD); if (node.getUserObject() instanceof DocNodeBase) { Object[] objectPath = node.getUserObjectPath(); DocPath selectionDocPath = new DocPath(); for (Object object : objectPath) { if (object instanceof DocNodeBase) { selectionDocPath.add((DocNodeBase) object); } else if (object instanceof String) { selectionDocPath.add(new DocNodeLiteral(object.toString() + "_string")); } } DocNodeBase selectedDocNode = (DocNodeBase) node.getUserObject(); if (selectedDocNode.getNodeType() == DocNodeBase.FILE && node.isLeaf()) { jcrDocDto = ((DocNodeFile) selectedDocNode).getJcrDocDto(); } else if (selectedDocNode.getNodeType() == DocNodeBase.VERSION) { jcrDocDto = ((DocNodeVersion) selectedDocNode).getJCRDocDto(); } else { jcrDocDto = null; } if (jcrDocDto != null) { if (!jcrDocDto.getbVersteckt() || bVersteckteAnzeigen) { dto2Components(); dropArea.setVisible(false); enableToolsPanelButtons(false, PanelBasis.ACTION_NEW, BUTTON_SCAN); enableToolsPanelButtons( selectedDocNode.getNodeType() == DocNodeBase.FILE || selectedDocNode.getNodeType() == DocNodeBase.VERSION && bHatMindestensEineSicherheitsStufe() && bHatDokumentenablage, PanelBasis.ACTION_UPDATE); wbuShowDoc.setEnabled(true); wbuSaveDoc.setEnabled(true); } } else { enableToolsPanelButtons(false, PanelBasis.ACTION_UPDATE); boolean b = fullDocPath.asDocNodeList().size() > 0 && selectedDocNode instanceof DocNodeJCR && bHatMindestensEineSicherheitsStufe() && bHatDokumentenablage; enableToolsPanelButtons(b, PanelBasis.ACTION_NEW, BUTTON_SCAN); dropArea.setVisible(b); } } } else { enableToolsPanelButtons(false, ACTION_UPDATE, PanelBasis.ACTION_NEW, BUTTON_SCAN); dropArea.setVisible(false); } }
From source file:org.apache.oodt.cas.workflow.gui.perspective.view.impl.DefaultTreeView.java
private DefaultMutableTreeNode buildTree(ModelGraph graph, ViewState state) { DefaultMutableTreeNode node = new DefaultMutableTreeNode(graph); DefaultMutableTreeNode metadataNode = new DefaultMutableTreeNode("static-metadata"); Metadata staticMetadata = new Metadata(); if (graph.getInheritedStaticMetadata(state) != null) { staticMetadata.replaceMetadata(graph.getInheritedStaticMetadata(state)); }//from www.j a va2 s . com if (graph.getModel().getStaticMetadata() != null) { staticMetadata.replaceMetadata(graph.getModel().getStaticMetadata()); } this.addMetadataNodes(metadataNode, staticMetadata); if (!metadataNode.isLeaf()) { node.add(metadataNode); } if (graph.getPreConditions() != null) { DefaultMutableTreeNode preConditions = new DefaultMutableTreeNode("pre-conditions"); List<ModelGraph> leafNodes = graph.getPreConditions().getLeafNodes(); for (ModelGraph cond : leafNodes) { DefaultMutableTreeNode condNode = new DefaultMutableTreeNode(cond); preConditions.add(condNode); } node.add(preConditions); } if (graph.getPostConditions() != null) { DefaultMutableTreeNode postConditions = new DefaultMutableTreeNode("post-conditions"); List<ModelGraph> leafNodes = graph.getPostConditions().getLeafNodes(); for (ModelGraph cond : leafNodes) { DefaultMutableTreeNode condNode = new DefaultMutableTreeNode(cond); postConditions.add(condNode); } node.add(postConditions); } for (ModelGraph child : graph.getChildren()) { if (!GuiUtils.isDummyNode(child.getModel())) { node.add(this.buildTree(child, state)); } } return node; }
From source file:org.apache.syncope.ide.netbeans.view.ResourceExplorerTopComponent.java
private void resourceExplorerTreeMouseClicked(final java.awt.event.MouseEvent evt) { if (evt.getButton() == MouseEvent.BUTTON1 && evt.getClickCount() == 2) { DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) resourceExplorerTree .getLastSelectedPathComponent(); DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) selectedNode.getParent(); String parentNodeName = parentNode == null ? null : String.valueOf(parentNode.getUserObject()); if (selectedNode.isLeaf() && StringUtils.isNotBlank(parentNodeName)) { String leafNodeName = (String) selectedNode.getUserObject(); try { if (PluginConstants.MAIL_TEMPLATES.equals(parentNodeName)) { openMailEditor(leafNodeName); } else if (PluginConstants.REPORT_XSLTS.equals(parentNodeName)) { openReportEditor(leafNodeName); }/*from w w w. ja v a 2 s .c o m*/ } catch (IOException e) { Exceptions.printStackTrace(e); } } } else if (evt.getButton() == MouseEvent.BUTTON3 && evt.getClickCount() == 1) { DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) resourceExplorerTree .getLastSelectedPathComponent(); String selectedNodeName = (String) selectedNode.getUserObject(); if (selectedNode.isLeaf() && !PluginConstants.ROOT_NAME.equals(selectedNodeName) && !PluginConstants.MAIL_TEMPLATES.equals(selectedNodeName) && !PluginConstants.REPORT_XSLTS.equals(selectedNodeName)) { leafRightClickAction(evt, selectedNode); } else if (PluginConstants.MAIL_TEMPLATES.equals(selectedNodeName)) { folderRightClickAction(evt, mailTemplates); } else if (PluginConstants.REPORT_XSLTS.equals(selectedNodeName)) { folderRightClickAction(evt, reportXslts); } else if (PluginConstants.ROOT_NAME.equals(selectedNodeName)) { rootRightClickAction(evt); } } }
From source file:org.languagetool.gui.ConfigurationDialog.java
@NotNull private MouseAdapter getMouseAdapter() { return new MouseAdapter() { private void handlePopupEvent(MouseEvent e) { JTree tree = (JTree) e.getSource(); TreePath path = tree.getPathForLocation(e.getX(), e.getY()); if (path == null) { return; }/* w w w. j a v a 2 s . com*/ DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); TreePath[] paths = tree.getSelectionPaths(); boolean isSelected = false; if (paths != null) { for (TreePath selectionPath : paths) { if (selectionPath.equals(path)) { isSelected = true; } } } if (!isSelected) { tree.setSelectionPath(path); } if (node.isLeaf()) { JPopupMenu popup = new JPopupMenu(); JMenuItem aboutRuleMenuItem = new JMenuItem(messages.getString("guiAboutRuleMenu")); aboutRuleMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { RuleNode node = (RuleNode) tree.getSelectionPath().getLastPathComponent(); Rule rule = node.getRule(); Language lang = config.getLanguage(); if (lang == null) { lang = Languages.getLanguageForLocale(Locale.getDefault()); } Tools.showRuleInfoDialog(tree, messages.getString("guiAboutRuleTitle"), rule.getDescription(), rule, rule.getUrl(), messages, lang.getShortCodeWithCountryAndVariant()); } }); popup.add(aboutRuleMenuItem); popup.show(tree, e.getX(), e.getY()); } } @Override public void mousePressed(MouseEvent e) { if (e.isPopupTrigger()) { handlePopupEvent(e); } } @Override public void mouseReleased(MouseEvent e) { if (e.isPopupTrigger()) { handlePopupEvent(e); } } }; }
From source file:org.mbari.aved.ui.classifier.knowledgebase.ConceptTree.java
/** * Makes the children nodes under the specified node invisible. * * @param node The node on which to act. *//*w ww. j a v a2 s. c om*/ private void makeChildrenInvisible(DefaultMutableTreeNode node) { Enumeration children = node.children(); while (children.hasMoreElements()) { DefaultMutableTreeNode childNode = (DefaultMutableTreeNode) children.nextElement(); if (!childNode.isLeaf()) { makeChildrenInvisible(childNode); TreeNode[] nodesFromRoot = childNode.getPath(); TreePath pathFromRoot = new TreePath(nodesFromRoot); collapsePath(pathFromRoot); } } }
From source file:org.mbari.aved.ui.classifier.knowledgebase.ConceptTree.java
/** * Makes the children nodes under the specified node visible. * * @param node The node on which to act. *///from w w w . j av a 2s . c o m private void makeChildrenVisible(DefaultMutableTreeNode node) { // RxTBD wcpr The Java API interaction of using TreeNodes and TreePaths // doesn't seem to make sense. There should be a cleaner way to implement // this method. if (node.isLeaf()) { return; } // Expand the node TreeConcept treeConcept = (TreeConcept) node.getUserObject(); treeConcept.lazyExpand(node); boolean allChildrenAreLeaves = true; Enumeration children = node.children(); while (children.hasMoreElements()) { DefaultMutableTreeNode childNode = (DefaultMutableTreeNode) children.nextElement(); if (!childNode.isLeaf()) { makeChildrenVisible(childNode); allChildrenAreLeaves = false; } } if (allChildrenAreLeaves) { DefaultMutableTreeNode lastNode = (DefaultMutableTreeNode) node.getLastChild(); TreeNode[] nodesFromRoot = node.getPath(); TreePath pathFromRoot = new TreePath(nodesFromRoot).pathByAddingChild(lastNode); makeVisible(pathFromRoot); } }