Package javax.swing.tree

Examples of javax.swing.tree.TreeNode.children()


public class TreeUtils {
    public static void expandAll(JTree tree, TreePath parent, boolean expand) {
        // Traverse children
        TreeNode node = (TreeNode) parent.getLastPathComponent();
        if (node.getChildCount() >= 0) {
            for (Enumeration e = node.children(); e.hasMoreElements(); ) {
                TreeNode n = (TreeNode) e.nextElement();
                TreePath path = parent.pathByAddingChild(n);
                expandAll(tree, path, expand);
            }
        }
View Full Code Here


    private void expandAll(TreePath parent, boolean expand) {
        // Traverse children
        TreeNode node = (TreeNode) parent.getLastPathComponent();
        if (node.getChildCount() >= 0) {
            for (Enumeration<?> e = node.children(); e.hasMoreElements();) {
                TreeNode n = (TreeNode) e.nextElement();
                TreePath path = parent.pathByAddingChild(n);
                expandAll(path, expand);
            }
        }
View Full Code Here

    {
      // parentNode was a leaf before this insertion event only if every one of
      // its current children is in the event's list of children
      boolean wasLeaf = true;
      List<?> eventChildren = Arrays.asList(e.getChildren());
      Enumeration<?> treeChildren = parentNode.children();
      while (wasLeaf && treeChildren.hasMoreElements())
      {
        if (!eventChildren.contains(treeChildren.nextElement()))
        {
          wasLeaf = false;
View Full Code Here

        else {
            TreePath parent = new TreePath(root);
            TreeNode node = (TreeNode) parent.getLastPathComponent();
            if (node.getChildCount() >= 0) {
                for (@SuppressWarnings("rawtypes")
                Enumeration e = node.children(); e.hasMoreElements();) {
                    TreeNode n = (TreeNode) e.nextElement();
                    TreePath path = parent.pathByAddingChild(n);
                    expandAll(tree, path, expand);
                }
            }
View Full Code Here

    private void expandAll(JTree tree, TreePath parent, boolean expand) {
        // Traverse children
        TreeNode node = (TreeNode) parent.getLastPathComponent();
        if (node.getChildCount() >= 0) {
            for (@SuppressWarnings("rawtypes")
            Enumeration e = node.children(); e.hasMoreElements();) {
                TreeNode n = (TreeNode) e.nextElement();
                TreePath path = parent.pathByAddingChild(n);
                expandAll(tree, path, expand);
            }
        }
View Full Code Here

                if (e.getClickCount() == 2) {
                    TreePath path = directoryChooser.getPathForLocation(e.getX(), e.getY());
                    if (path != null && path.equals(directoryChooser.getSelectionPath()) &&
                        directoryChooser.getSelectedFiles().length > 0) {
                        TreeNode o = (TreeNode) path.getLastPathComponent();
                        if (o.isLeaf() || !o.children().hasMoreElements())
                            actionListener.actionPerformed(new ActionEvent(directoryChooser, 0, null));
                    }
                }
            }
        });
View Full Code Here

  public void expandAll(JTree tree, TreePath parent, boolean expand) {
    // Traverse children
    final TreeNode node = (TreeNode) parent.getLastPathComponent();
    if (node.getChildCount() >= 0) {

      for (final Enumeration<TreeNode> e = node.children(); e.hasMoreElements();) {

        final TreeNode n = e.nextElement();
        final TreePath path = parent.pathByAddingChild(n);
        expandAll(tree, path, expand);
      }
View Full Code Here

  private void expandPath(JTree tree, TreePath path) {
    tree.expandPath(path);

    final TreeNode node = ((TreeNode)path.getLastPathComponent());
    final Enumeration children = node.children();
    while (children.hasMoreElements()) {
      TreeNode child = (TreeNode)children.nextElement();
      expandPath(tree, path.pathByAddingChild(child));
    }
  }
View Full Code Here

  }

  private void collapsePath(JTree tree, TreePath path) {

    final TreeNode node = ((TreeNode)path.getLastPathComponent());
    final Enumeration children = node.children();
    while (children.hasMoreElements()) {
      TreeNode child = (TreeNode)children.nextElement();
      collapsePath(tree, path.pathByAddingChild(child));
    }
View Full Code Here

    // Traverse children
    TreeNode node = (TreeNode) parent.getLastPathComponent();

    if (node.getChildCount() >= 0)
    {
      for (Enumeration e = node.children(); e.hasMoreElements();)
      {
        TreeNode n = (TreeNode) e.nextElement();
        TreePath path = parent.pathByAddingChild(n);

        if (desiredLevel > 0)
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.