Package javax.swing.tree

Examples of javax.swing.tree.DefaultMutableTreeNode


    private void removeNode(DefaultMutableTreeNode child) {
       DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
       model.removeNodeFromParent(child);
   
       // remove empty branches above (needed for the file tree panel)
       DefaultMutableTreeNode parent = (DefaultMutableTreeNode) child.getParent();
       NodeElement ne;
       while (parent != null) {
         ne = ((NodeElement) child.getUserObject());
         if (ne.getCount() == 0 && parent.getChildCount() == 0) {
           DefaultMutableTreeNode newParent = null;

           try {
             newParent = (DefaultMutableTreeNode) parent.getParent();
           } catch (Exception e) {}
            
View Full Code Here


         }
       }
    }


    DefaultMutableTreeNode node = null;
    for (int i=0; i<vSubNodes.size(); i++) {
      BasicNode bNode = new BasicNode(null, (String) vSubNodes.elementAt(i));
//TODO      bNode.setClassName(nodes[i].getClassName());
      bNode.setExpandedIcon(loadIcon("question.gif"));
      bNode.setNormalIcon(loadIcon("question.gif"));
      node = new DefaultMutableTreeNode(bNode);
      parent.add(node);
    }
  }
View Full Code Here

  public DefaultMutableTreeNode addServerNodes() throws Exception {
      Object[] nodes = new Object[5];
      BasicNode rootNode = new BasicNode(null, "xmlBlaster");
      rootNode.setExpandedIcon(loadIcon("globe.gif"));
      rootNode.setNormalIcon(loadIcon("globe.gif"));
      top = new DefaultMutableTreeNode(rootNode);

      parent = top;
      nodes[0] = top;
      DefaultMutableTreeNode node = null;
     
      ConnectorFactory connectorFactory = ConnectorFactory.getInstance(this.glob);
      connectorFactory.getMBeanServer("127.0.0.1");
      String[] servers = connectorFactory.getMBeanServerList();
     
      if (servers == null) throw new Exception("could not connect to any host! ");
      for (int i=0; i<servers.length; i++) {
        BasicNode bNode = new BasicNode(null, servers[i]);
        bNode.setExpandedIcon(loadIcon("node.gif"));
        bNode.setNormalIcon(loadIcon("node.gif"));
        node = new DefaultMutableTreeNode(bNode);
        parent.add(node);
      }
      parent = node;
      nodes[1] = parent;
View Full Code Here

   
  /**
   *
   */
  public Component3DTree() {
    DefaultMutableTreeNode root=new DefaultMutableTreeNode();
    model= new DefaultTreeModel(root, true);
    setModel(model);
    setCellRenderer(new SceneGraphTreeRenderer());
    setRootVisible(false);
  }
View Full Code Here

      return;
    }
    for (Enumeration e = rootNode.depthFirstEnumeration(); e.hasMoreElements();) {
      Object elt = e.nextElement();
      if (!(elt instanceof DefaultMutableTreeNode)) continue;
      DefaultMutableTreeNode node = (DefaultMutableTreeNode)elt;
      Object u = node.getUserObject();
      if ((u!=null) && (u.equals(o))) {
        TreePath path = new TreePath(node.getPath());
        scrollPathToVisible(path);
        setSelectionPath(path);
        return;
      }
    }
View Full Code Here

  public void setSelectedValueById(String id) {
    if (id==null) return;
    for (Enumeration e = rootNode.depthFirstEnumeration(); e.hasMoreElements();) {
      Object elt = e.nextElement();
      if (!(elt instanceof DefaultMutableTreeNode)) continue;
      DefaultMutableTreeNode node = (DefaultMutableTreeNode)elt;
      if (id.equals(DataInfo.getId(node.getUserObject()))) {
        TreePath path = new TreePath(node.getPath());
        scrollPathToVisible(path);
        setSelectionPath(path);
        return;
      }
    }
View Full Code Here

    // Don't remove the nodes while iterating, safer to do it after?
    // May be useless, a pity I'm too lazy to investigate...
    Vector nodes = new Vector();
    for (Enumeration e = rootNode.children(); e.hasMoreElements();) {
      DefaultMutableTreeNode child = (DefaultMutableTreeNode)e.nextElement();
      if (child.getUserObject()==o) nodes.add(child);
    }
    for (Iterator it = nodes.iterator(); it.hasNext();)
      rootNode.remove((MutableTreeNode)it.next());
   
   
View Full Code Here

    setFilterValidity(true);
  }

  protected void changeSource(DataSource ds, DataSource old) {
    for (Enumeration e = rootNode.children(); e.hasMoreElements();) {
      DefaultMutableTreeNode child = (DefaultMutableTreeNode)e.nextElement();
      if (child.getUserObject()==old) ((DataSourceNode)child).changeSource(ds);
    }
  }
View Full Code Here

    }
  }

  protected void changeCollection(DataSourceCollection dsc, DataSourceCollection old) {
    for (Enumeration e = rootNode.children(); e.hasMoreElements();) {
      DefaultMutableTreeNode child = (DefaultMutableTreeNode)e.nextElement();
      if (child.getUserObject()==old) ((CollectionNode)child).changeCollection(dsc);
    }
  }
View Full Code Here

        targetToNodeTable = new HashMap();

        // Create help tree
        rootNode = new HelpNode();

        rootTreeNode = new DefaultMutableTreeNode();
        DefaultTreeModel treeModel = new DefaultTreeModel(rootTreeNode);
        helpTree = new JTree();
        helpTree.setModel(treeModel);
        helpTree.setRootVisible(false);
        helpTree.setShowsRootHandles(true);
        helpTree.addTreeSelectionListener(this);

        // Renderer
        DefaultTreeCellRenderer  helpTreeRenderer = (DefaultTreeCellRenderer) helpTree.getCellRenderer();
        helpTreeRenderer.setOpenIcon(resources.getIcon("folderIcon"));
        helpTreeRenderer.setClosedIcon(resources.getIcon("folderIcon"));
        helpTreeRenderer.setLeafIcon(resources.getIcon("leafIcon"));

        createHelpContents();


        // Create help search panel

        // search tree
        searchRootTreeNode = new DefaultMutableTreeNode();
        searchTreeModel = new DefaultTreeModel(searchRootTreeNode);
        searchTree = new JTree();
        searchTree.setModel(searchTreeModel);
        searchTree.setRootVisible(false);
        searchTree.setShowsRootHandles(true);
View Full Code Here

TOP

Related Classes of javax.swing.tree.DefaultMutableTreeNode

Copyright © 2018 www.massapicom. 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.