当前位置: 首页>>代码示例>>Java>>正文


Java DefaultMutableTreeNode.getChildCount方法代码示例

本文整理汇总了Java中javax.swing.tree.DefaultMutableTreeNode.getChildCount方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultMutableTreeNode.getChildCount方法的具体用法?Java DefaultMutableTreeNode.getChildCount怎么用?Java DefaultMutableTreeNode.getChildCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.tree.DefaultMutableTreeNode的用法示例。


在下文中一共展示了DefaultMutableTreeNode.getChildCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getLowerFileModel

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
public void getLowerFileModel(DefaultMutableTreeNode node) {

    if (node instanceof ProjectPanelTreeNode) {
     	ProjectPanelTreeNode pptn = (ProjectPanelTreeNode)node;
      if (pptn.isFolder()) {
        for (int i = 0; i < pptn.getChildCount(); i++) {
         	getLowerFileModel((DefaultMutableTreeNode)pptn.getChildAt(i));
        }
      }
      else if (pptn.isFile()) {
      	ProjectFileEntry pfe = (ProjectFileEntry)pptn.getObject();
      	lowerFiles.addElement(pfe);
      }
    }
    else {
    	for (int i = 0; i < node.getChildCount(); i++) {
      	getLowerFileModel((DefaultMutableTreeNode)node.getChildAt(i));
      }
    }  }
 
开发者ID:FJplant,项目名称:AntIDE,代码行数:20,代码来源:ProjectExplorer.java

示例2: getTreeCellRendererComponent

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf,
		int row, boolean hasFocus) {
	super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
	DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
	if (node.getChildCount() > 0) {
		setIcon(this.pack);
	} else if (getFileName(node).endsWith(".class") || getFileName(node).endsWith(".java")) {
		setIcon(this.java_image);
	} else if (getFileName(node).endsWith(".yml") || getFileName(node).endsWith(".yaml")) {
		setIcon(this.yml_image);
	} else {
		setIcon(this.file_image);
	}

	return this;
}
 
开发者ID:KevinPriv,项目名称:Luyten4Forge,代码行数:18,代码来源:CellRenderer.java

示例3: getPath

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
private TreeNode[] getPath(Object node, String deap, String item, boolean debug) {
    if (node instanceof DefaultMutableTreeNode) {
        DefaultMutableTreeNode dmtn = (DefaultMutableTreeNode) node;
        if (debug) {
            System.out.println(deap + dmtn.toString());
        }
        if (dmtn.toString().equals(item)) {
            if (debug) {
                System.out.println("EQUAL!!! <" + item + ">");
            }
            return dmtn.getPath();
        }
        TreeNode[] curPath;
        for (int i = 0; i < dmtn.getChildCount(); i++) {
            curPath = getPath(dmtn.getChildAt(i), deap + "__", item, debug);
            if (curPath != null) {
                return curPath;
            }
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:ManageInspectionsOperatot.java

示例4: isSelected

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
State isSelected( DefaultMutableTreeNode node ) {
    boolean hasEnabled = false;
    boolean hasDisabled = false;
    List<DefaultMutableTreeNode> todo = new LinkedList<>();

    todo.add(node);
    
    while (!todo.isEmpty()) {
        DefaultMutableTreeNode current = todo.remove(0);
        Object o = current.getUserObject();
        if ( o instanceof HintMetadata ) {
            HintMetadata hint = (HintMetadata)o;
            if (isEnabled(hint)) {
                hasEnabled = true;
            } else {
                hasDisabled = true;
            }
        } else if (o instanceof HintCategory) {
            for (int i = 0; i < current.getChildCount(); i++) {
                todo.add((DefaultMutableTreeNode) current.getChildAt(i));
            }
        }
    }
    return hasEnabled ? hasDisabled ? State.OTHER : State.SELECTED : State.NOT_SELECTED;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:HintsPanelLogic.java

示例5: retrieveDeletedFiles

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
private void retrieveDeletedFiles(final Node[] activatedNodes, final RevertPanel p) {
    VCSContext ctx = VCSContext.forNodes(activatedNodes);
    Set<VCSFileProxy> rootSet = ctx.getRootFiles();        
    if(rootSet == null || rootSet.size() < 1) { 
        return;
    }                                        
    DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode();
    for (VCSFileProxy root : rootSet) {            
        PlainFileNode rfn = new PlainFileNode(root);
        populateNode(rfn, root, !VersioningSupport.isFlat(root));
        if(rfn.getChildCount() > 0) {
            rootNode.add(rfn);
        }
    }
    if(rootNode.getChildCount() > 0) {
        p.setRootNode(rootNode);
    } else {
        p.setRootNode(null);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:RevertDeletedAction.java

示例6: getTreeCellRendererComponent

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf,
                                              int row, boolean hasFocus) {
    super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
    DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
    if (node.getChildCount() > 0) {
        setIcon(this.pack);
    } else if (getFileName(node).endsWith(".class") || getFileName(node).endsWith(".java")) {
        setIcon(this.java_image);
    } else if (getFileName(node).endsWith(".yml") || getFileName(node).endsWith(".yaml")) {
        setIcon(this.yml_image);
    } else {
        setIcon(this.file_image);
    }

    return this;
}
 
开发者ID:hsswx7,项目名称:CS4500GroupProject,代码行数:18,代码来源:CellRenderer.java

示例7: haveCompleteNode

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
private boolean haveCompleteNode(JTree tree) {
    int[] selRows = tree.getSelectionRows();
    TreePath path = tree.getPathForRow(selRows[0]);
    DefaultMutableTreeNode first =
        (DefaultMutableTreeNode)path.getLastPathComponent();
    int childCount = first.getChildCount();
    // first has children and no children are selected.
    if(childCount > 0 && selRows.length == 1)
        return false;
    // first may have children.
    for(int i = 1; i < selRows.length; i++) {
        path = tree.getPathForRow(selRows[i]);
        DefaultMutableTreeNode next =
            (DefaultMutableTreeNode)path.getLastPathComponent();
        if(first.isNodeChild(next)) {
            // Found a child of first.
            if(childCount > selRows.length-1) {
                // Not all children of first are selected.
                return false;
            }
        }
    }
    return true;
}
 
开发者ID:Panzer1119,项目名称:JAddOn,代码行数:25,代码来源:TreeTransferHandler.java

示例8: FmtSpaces

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
/** Creates new form FmtSpaces */
private FmtSpaces() {
    initComponents();
    model = createModel();
    cfgTree.setModel(model);
    cfgTree.setRootVisible(false);
    cfgTree.setShowsRootHandles(true);
    cfgTree.setCellRenderer(this);
    cfgTree.setEditable(false);
    cfgTree.addMouseListener(this);
    cfgTree.addKeyListener(this);
    
    dr.setIcon(null);
    dr.setOpenIcon(null);
    dr.setClosedIcon(null);
    
    DefaultMutableTreeNode root = (DefaultMutableTreeNode)model.getRoot();
    for( int i = root.getChildCount(); i >= 0; i-- ) {
        cfgTree.expandRow(i);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:FmtSpaces.java

示例9: sortNodesDescending

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
/**
 * Sort nodes descending.
 *
 * @param node the node
 * @param treeModel the tree model
 */
private void sortNodesDescending(DefaultMutableTreeNode node, DefaultTreeModel treeModel) {
	boolean unsorted = true;

	while (unsorted) {
		unsorted = false;
		for (int i = 0; i < node.getChildCount() - 1; i++) {
			ThreadInfoStorageAgent tiaFirst = (ThreadInfoStorageAgent) ((DefaultMutableTreeNode) node.getChildAt(i)).getUserObject();
			ThreadInfoStorageAgent tiaSecond = (ThreadInfoStorageAgent) ((DefaultMutableTreeNode) node.getChildAt(i+1)).getUserObject();
			
			if (tiaFirst.getXYSeriesMap().get("TOTAL_CPU_SYSTEM_TIME").getMaxY() < tiaSecond.getXYSeriesMap().get("TOTAL_CPU_SYSTEM_TIME").getMaxY()) {
				treeModel.insertNodeInto((MutableTreeNode) node.getChildAt(i+1), node, i);
				unsorted = true;
			}
		}
	}
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:23,代码来源:ThreadInfoStorageTree.java

示例10: getMultipleNodesAvailable

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
/**
 * Provides the Vector of all currently available nodes of the same kind as the current node.
 *
 * @param currNode The current node of the object structure
 * @return the multiple nodes available
 */
private Vector<DefaultMutableTreeNode> getMultipleNodesAvailable(DefaultMutableTreeNode currNode) {
	
	// --- The result vector of all needed nodes ------------------------------------ 
	Vector<DefaultMutableTreeNode> nodesFound = new Vector<DefaultMutableTreeNode>();
	// --- Can we find the number of similar nodes to the current one? -------------- 
	DynType currDT = (DynType) currNode.getUserObject();
	
	// --- The current parentNode and the position of the current node --------------
	DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) currNode.getParent();

	// --- Search for all similar nodes --------------------------------------------- 
	for (int i = 0; i < parentNode.getChildCount(); i++) {
		DefaultMutableTreeNode checkNode = (DefaultMutableTreeNode) parentNode.getChildAt(i);
		DynType checkDT = (DynType) checkNode.getUserObject();
		if (checkDT.equals(currDT)) {
			nodesFound.add(checkNode);
		} 
	}
	return nodesFound;

}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:28,代码来源:DynFormBase.java

示例11: getTopLevelIndicators

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
public AIndicator[][] getTopLevelIndicators()
{
	AIndicator[][] indicators = new AIndicator[rootNodes.length][];
	
	int k = 0;
	for(DefaultMutableTreeNode tn: rootNodes)
	{
		indicators[k] = new AIndicator[tn.getChildCount()];
		for(int c = 0;c < tn.getChildCount(); c++)
		{
			indicators[k][c] = (AIndicator)((DefaultMutableTreeNode)tn.getChildAt(c)).getUserObject();
		}
		k++;
	}
	
	return indicators;
}
 
开发者ID:lead4good,项目名称:open-java-trade-manager,代码行数:18,代码来源:IndicatorFactory.java

示例12: setJPanelInvisibleAndSmall

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
/**
 * Sets the invisible.
 *
 * @param parentNode the new invisible
 * @return the rectangle
 */
private Rectangle setJPanelInvisibleAndSmall(DefaultMutableTreeNode parentNode) {
	
	Rectangle feBounds = null; // --- First element Bounds ------
	DynType parentDT = (DynType) parentNode.getUserObject();
	
	for (int i = 0; i < parentNode.getChildCount(); i++) {
		DefaultMutableTreeNode childNode = (DefaultMutableTreeNode) parentNode.getChildAt(i);
		if (childNode.getChildCount()>0) {
			// --- recursively edit all sub panels --------------
			feBounds = this.setJPanelInvisibleAndSmall(childNode);
		}
		DynType dt = (DynType) childNode.getUserObject();
		
		if (feBounds==null) {
			feBounds = dt.getPanel().getBounds();
		}
		dt.getPanel().setVisible(false);
		dt.getPanel().setBounds(feBounds);
	}
	
	this.setPanelBounds(parentDT.getPanel());		
	return feBounds;
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:30,代码来源:DynForm.java

示例13: updateGui

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
/**
 * Update the visualizer with new data.
 */
private synchronized void updateGui(SampleResult res) {
    // Add sample
    DefaultMutableTreeNode currNode = new SearchableTreeNode(res, treeModel);
    treeModel.insertNodeInto(currNode, root, root.getChildCount());
    addSubResults(currNode, res);
    // Add any assertion that failed as children of the sample node
    AssertionResult[] assertionResults = res.getAssertionResults();
    int assertionIndex = currNode.getChildCount();
    for (AssertionResult assertionResult : assertionResults) {
        if (assertionResult.isFailure() || assertionResult.isError()) {
            DefaultMutableTreeNode assertionNode = new SearchableTreeNode(assertionResult, treeModel);
            treeModel.insertNodeInto(assertionNode, currNode, assertionIndex++);
        }
    }

    if (root.getChildCount() == 1) {
        jTree.expandPath(new TreePath(root));
    }
    if (autoScrollCB.isSelected() && root.getChildCount() > 1) {
        jTree.scrollPathToVisible(new TreePath(new Object[] { root,
                treeModel.getChild(root, root.getChildCount() - 1) }));
    }
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:27,代码来源:ViewResultsFullVisualizer.java

示例14: findNode

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
private DefaultMutableTreeNode findNode(DefaultMutableTreeNode parent, String userObject) {
    for (int i=0; i<parent.getChildCount(); i++) {
        DefaultMutableTreeNode child = (DefaultMutableTreeNode)parent.getChildAt(i);
        if (userObject.equals(child.getUserObject())) {
            return child;
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:BindingCustomizer.java

示例15: addProjectTabInternal

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
/**
 * Adds a Project-Tab and a new node (child of a specified parent) to the ProjectWindow.
 *
 * @param projectWindowTab the project window tab
 * @return the default mutable tree node
 */
private DefaultMutableTreeNode addProjectTabInternal(ProjectWindowTab projectWindowTab) {

	// --- create Node ----------------------
	DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(projectWindowTab);
	DefaultMutableTreeNode pareNode = null;
	JTabbedPane tabbedPaneParent = null;

	String parentName = projectWindowTab.getParentName();

	// --- add to the TreeModel -------------
	if (parentName != null) {
		pareNode = getTreeNode(parentName);
		ProjectWindowTab pareNodePWT = (ProjectWindowTab) pareNode.getUserObject();
		tabbedPaneParent = pareNodePWT.getCompForChildComp();
		// --- add ChangeListener -----------
		this.addChangeListener(tabbedPaneParent);

	} else {
		pareNode = this.getRootNode();
		tabbedPaneParent = projectViewRightTabs;
	}

	if (projectWindowTab.getIndexPosition() != -1 && projectWindowTab.getIndexPosition() < pareNode.getChildCount()) {
		// --- Add to parent node/tab at index position ----
		pareNode.insert(newNode, projectWindowTab.getIndexPosition());
		tabbedPaneParent.insertTab(projectWindowTab.getTitle(), projectWindowTab.getIcon(), projectWindowTab.getJComponentForVisualization(), projectWindowTab.getTipText(), projectWindowTab.getIndexPosition());
	} else {
		// --- Just add to parent node/tab -----------------
		pareNode.add(newNode);
		tabbedPaneParent.addTab(projectWindowTab.getTitle(), projectWindowTab.getIcon(), projectWindowTab.getJComponentForVisualization(), projectWindowTab.getTipText());
	}

	// --- refresh view ---------------------
	this.getTreeModel().reload();
	this.projectTreeExpand2Level(3, true);
	return newNode;
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:44,代码来源:ProjectWindow.java


注:本文中的javax.swing.tree.DefaultMutableTreeNode.getChildCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。