Example usage for javax.swing JTree getModel

List of usage examples for javax.swing JTree getModel

Introduction

In this page you can find the example usage for javax.swing JTree getModel.

Prototype

public TreeModel getModel() 

Source Link

Document

Returns the TreeModel that is providing the data.

Usage

From source file:Main.java

public static void visitAllExpandedNodes(JTree tree) {
    TreeNode root = (TreeNode) tree.getModel().getRoot();
    visitAllExpandedNodes(tree, new TreePath(root));
}

From source file:Main.java

public static TreePath findByName(JTree tree, String[] names) {
    TreeNode root = (TreeNode) tree.getModel().getRoot();
    return find(tree, new TreePath(root), names, 0);
}

From source file:Main.java

/**
 * Determines whether the given JTree represents a TsSapInvoiceExternal from the COAST system
 * //ww  w. j a v  a2s.co  m
 * @return True, if tree is a TsSapInvoiceExternal (converted from the corresponding XML file). False, if it is not.
 */
public static boolean isTsSapInvoiceListExternal(JTree tree) {
    Node root = (Node) tree.getModel().getRoot();
    return root.getNodeName().equals("com.scandlines.coast.common.payment.TsSapInvoiceListExternal");
}

From source file:Main.java

static public void expandAll(JTree tree, boolean expand) {
    Object root = tree.getModel().getRoot();
    // Traverse tree from root
    expandAll(tree, new TreePath(root), expand);
}

From source file:Main.java

public static void expandTree(JTree tree) {
    expandTree(tree, new TreePath(tree.getModel().getRoot()));
}

From source file:Main.java

public static Enumeration<TreePath> saveExpansionState(JTree tree) {
    return tree.getExpandedDescendants(new TreePath(tree.getModel().getRoot()));
}

From source file:TreeUtil.java

public static void expandAll(JTree tree, boolean expand) {
    TreeNode root = (TreeNode) tree.getModel().getRoot();
    // Traverse tree from root
    expandAll(tree, new TreePath(root), expand);
}

From source file:Main.java

public static void expandTree(JTree tree) {
    DefaultMutableTreeNode root = (DefaultMutableTreeNode) tree.getModel().getRoot();
    @SuppressWarnings("unchecked")
    Enumeration<DefaultMutableTreeNode> e = root.breadthFirstEnumeration();
    while (e.hasMoreElements()) {
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) e.nextElement();
        if (node.isLeaf())
            continue;
        int row = tree.getRowForPath(new TreePath(node.getPath()));
        tree.expandRow(row);//from  w ww  .  ja  v  a2 s  .co  m
    }
}

From source file:Main.java

public static void expandTree(JTree tree, boolean expand) {
    expandAll(tree, new TreePath((TreeNode) tree.getModel().getRoot()), expand);
}

From source file:Main.java

public static void expand(JTree tree, int level) {
    DefaultMutableTreeNode currentNode = (DefaultMutableTreeNode) tree.getModel().getRoot();
    while (currentNode != null) {
        if (currentNode.getLevel() <= level) {
            tree.expandPath(new TreePath(currentNode.getPath()));
        }//from ww  w .ja  v a2  s  .  c o  m
        currentNode = currentNode.getNextNode();
    }
}