Package javax.swing.tree

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


    DefaultMutableTreeNode n = new DefaultMutableTreeNode("ABC", false);
    harness.check(n.getUserObject(), "ABC");
    harness.check(n.getAllowsChildren(), false);
    harness.check(n.getLevel(), 0);
    harness.check(n.getChildCount(), 0);
    harness.check(n.children(), DefaultMutableTreeNode.EMPTY_ENUMERATION);
    harness.check(n.getDepth(), 0);

    // try null argument
    n = new DefaultMutableTreeNode(null, true);
    harness.check(n.getUserObject(), null);
View Full Code Here


    }
  }
 
  protected void sortTreeModel(Comparator comparator){
    DefaultMutableTreeNode rootNode = (DefaultMutableTreeNode) getTreeModel().getRoot();   
    Enumeration<DefaultMutableTreeNode> enumeration = rootNode.children();   
    List<DefaultMutableTreeNode> list = Collections.list(enumeration);       
    Collections.sort(list,comparator);   
    rootNode.removeAllChildren();   
    for(DefaultMutableTreeNode node:list){
      rootNode.add(node);
View Full Code Here

      List<String> fileList = new ArrayList<String>();
      for (TreePath path : tps) {
        DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent();
        Object obj = node.getUserObject();
        if (obj instanceof String) {
          Enumeration en = node.children();
          while (en.hasMoreElements()) {
            DefaultMutableTreeNode child = (DefaultMutableTreeNode) en.nextElement();
            obj = child.getUserObject();
            if (obj instanceof Wrapper) {
              Wrapper<String> wrapper = (Wrapper<String>)obj;
View Full Code Here

* with an already existing TreeNode.
*/
outerFor:
    for (int i = 0; i < packages.length; i++) {
      String packageName = packages[i];
      Enumeration enumeration = current.children();

      while (enumeration.hasMoreElements()) {
        DefaultMutableTreeNode child =
          (DefaultMutableTreeNode) enumeration.nextElement();
        String childName = child.getUserObject().toString();
View Full Code Here

          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

          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

      DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot();
      assertEquals("Annotations", root.getUserObject().toString());
      DefaultMutableTreeNode typeNode = (DefaultMutableTreeNode) root.getChildAt(0);
      assertEquals("Example", typeNode.getUserObject().toString());
      DefaultMutableTreeNode fsNode = (DefaultMutableTreeNode) typeNode.getChildAt(0);
      Enumeration children = fsNode.children();
      assertEquals("begin = 1", ((DefaultMutableTreeNode) children.nextElement()).getUserObject()
              .toString());
      assertEquals("end = 5", ((DefaultMutableTreeNode) children.nextElement()).getUserObject()
              .toString());
      assertEquals("floatFeature = " + (float) 99.99, ((DefaultMutableTreeNode) children
View Full Code Here

          return root;
        }
        else {
            // Traverse children
              if (node.getChildCount() >= 0) {
                  for (Enumeration<TreeNode> e = node.children(); e.hasMoreElements(); ) {
                      TreePath path = root.pathByAddingChild(e.nextElement());
                      TreePath result = findComponentInTree(path, c);
                      // Found a match
                      if (result != null) {
                          return result;
View Full Code Here

          return root;
        }
        else {
            // Traverse children
              if (node.getChildCount() >= 0) {
                  for (Enumeration<TreeNode> e = node.children(); e.hasMoreElements(); ) {
                      TreePath path = root.pathByAddingChild(e.nextElement());
                      TreePath result = findComponentInTree(path, c);
                      // Found a match
                      if (result != null) {
                          return result;
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

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.