Package javax.swing.tree

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


    };
  }

  public void removeChildElements(final Object key) {
    final DefaultMutableTreeNode node = getNode(key);
    final Enumeration<?> children = node.children();
    while (children.hasMoreElements()) {
      final Node child = (Node) children.nextElement();
      final Object childKey = child.getKey();
      if (childKey != null) {
        removeChildElements(childKey);
View Full Code Here


            Enumeration enumRoot = rootNode_.children();
            try {
                // Start the animation
                while (showAnimation_ && enumRoot.hasMoreElements()) {
                    DefaultMutableTreeNode childNode = (DefaultMutableTreeNode) enumRoot.nextElement();
                    Enumeration enumChild = childNode.children();

                    while (showAnimation_ && enumChild.hasMoreElements()) {
                        DefaultMutableTreeNode node = (DefaultMutableTreeNode) enumChild.nextElement();

                        if (node.isLeaf()) {
View Full Code Here

   */
  public List<Object> getChildUserObjects(Object parentUserObject) {
    DefaultMutableTreeNode parent = obj2node.get(parentUserObject);
    List<Object> list = new ArrayList<Object>();
    if (parent != null) {
      Enumeration<?> children = parent.children();
      while (children.hasMoreElements()) {
        DefaultMutableTreeNode child = (DefaultMutableTreeNode) children.nextElement();
        list.add(child.getUserObject());
      }
    }
View Full Code Here

   * Set a child node of the current node with the given user object.
   * @param userObject User object of the child node.
   */
  public void setCurrentChild(Object userObject) {
    DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getSelectionPath().getLastPathComponent();
    Enumeration<?> children = node.children();
    while (children.hasMoreElements()) {
      DefaultMutableTreeNode child = (DefaultMutableTreeNode) children.nextElement();
      Object childObject = child.getUserObject();
      if (childObject.equals(userObject)) {
        setCurrentNode(childObject);
View Full Code Here

   * @param objects User Objects, starting with root object (not <i>null</i>!).
   */
  public void removeUserObjectPath(Object[] objects) {
    DefaultMutableTreeNode node = rootNode;
    for (int i = 1; i < objects.length && node != null; i++) {
      Enumeration<?> en = node.children();
      boolean found = false;
      while (en.hasMoreElements() && !found) {
        DefaultMutableTreeNode child = (DefaultMutableTreeNode) en.nextElement();
        if (child.getUserObject().equals(objects[i])) {
          node = child;
View Full Code Here

 
  @Override
  public void treeCollapsed(TreeExpansionEvent event) {
    DefaultMutableTreeNode node = (DefaultMutableTreeNode) event.getPath().getLastPathComponent();
    @SuppressWarnings("unchecked")
    Enumeration<DefaultMutableTreeNode> children = node.children();
    while (children.hasMoreElements()) {
      DefaultMutableTreeNode child = children.nextElement();
      log.debug("removing children of " + ((NodeInfo) child.getUserObject()).getFullName());
      child.removeAllChildren();
    }
View Full Code Here

        File f = (File) table.getValueAt(rowIndex, 0);
        if (f.isDirectory()) {
            final TreePath selectionPath = tree.getSelectionPath();
            DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode)
                selectionPath.getLastPathComponent();
            for (Enumeration<DefaultMutableTreeNode> e = treeNode.children(); e.hasMoreElements();) {
                DefaultMutableTreeNode n = e.nextElement();
                if (n.getUserObject().equals(f)) {
                    final TreePath path = new TreePath(n.getPath());
                    tree.expandPath(path);
                    tree.setSelectionPath(path);
View Full Code Here

    public void treeWillCollapse(TreeExpansionEvent event) {
        DefaultMutableTreeNode collapsingNode = (DefaultMutableTreeNode) event.getPath().getLastPathComponent();
        ProfileResourceNode prn = (ProfileResourceNode) collapsingNode.getUserObject();
        profileForm.getInMemoryNodes().remove(prn.getId());
       
        for (Enumeration<DefaultMutableTreeNode> e = collapsingNode.children(); e.hasMoreElements();) {
            DefaultMutableTreeNode nodeToRemove = e.nextElement();
            final ProfileResourceNode node = (ProfileResourceNode) nodeToRemove.getUserObject();
            profileForm.getInMemoryNodes().remove(node.getId());
        }
        collapsingNode.removeAllChildren();
View Full Code Here

            Long parentId = node.getParentId() == null ? -1L : node.getParentId();
            DefaultMutableTreeNode parent = profileForm.getInMemoryNodes().get(parentId);
            if (parent != null) {
                parent.setAllowsChildren(true);
                boolean updated = false;
                for (Enumeration<DefaultMutableTreeNode> e = parent.children();
                    e.hasMoreElements() && !updated;) {
                    DefaultMutableTreeNode childNode = e.nextElement();
                    if (childNode.getUserObject().equals(node)) {
                        childNode.setUserObject(node);
                        childNode.setAllowsChildren(node.allowsChildren());
View Full Code Here

                if (root == null && (items.length > 0 || createEmpty)) {
                    root = new DefaultMutableTreeNode(groupName);
                    treeRoot.add(root);
                    groupNodes.put(groupKey, root);
                } else if (root != null) {
                    Enumeration<?> children = root.children();
                    while (children.hasMoreElements()) {
                        treeNodes.add((DefaultMutableTreeNode) children.nextElement());
                    }
                }
            }
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.