Example usage for javax.swing.tree DefaultMutableTreeNode getRoot

List of usage examples for javax.swing.tree DefaultMutableTreeNode getRoot

Introduction

In this page you can find the example usage for javax.swing.tree DefaultMutableTreeNode getRoot.

Prototype

public TreeNode getRoot() 

Source Link

Document

Returns the root of the tree that contains this node.

Usage

From source file:dotaSoundEditor.Controls.ItemPanel.java

private void currentTreeSelectionChanged(TreeSelectionEvent evt) {
    DefaultMutableTreeNode node = (DefaultMutableTreeNode) currentTree.getLastSelectedPathComponent();
    if (node == null) {
        return;//from   w  w  w. jav  a2  s .com
    }
    //get highest parent of selected node
    while (node.getParent() != null && !node.getParent().equals(node.getRoot())) {
        node = (DefaultMutableTreeNode) node.getParent();
    }

    NamedItem clickedItem = new NamedItem(node.getUserObject().toString(), this.getCurrentScriptString());
    fillImageFrame(clickedItem);
    itemLabel.setText("Item: " + clickedItem.getFriendlyName());

}

From source file:org.carewebframework.help.javahelp.HelpView.java

/**
 * Initializes the topic tree, if there is one associated with this view.
 *///from www. j  a  va 2  s  .c om
private void initTopicTree() {
    DefaultMutableTreeNode topicTree = getDataAsTree();

    if (topicTree != null) {
        initTopicTree(rootNode, topicTree.getRoot());
    }

}