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


Java DefaultMutableTreeNode.breadthFirstEnumeration方法代码示例

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


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

示例1: filterNodeByKey

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
/**
 * Filter node by key.
 *
 * @param node the node
 * @param key the key
 */
private void filterNodeByKey(DefaultMutableTreeNode node, String key){
		
		Vector<DefaultMutableTreeNode> toDeleteVect= new Vector<DefaultMutableTreeNode>();
		
		@SuppressWarnings("unchecked")
		Enumeration<DefaultMutableTreeNode> e = node.breadthFirstEnumeration();
		if(e != null){
			while (e.hasMoreElements()){
				DefaultMutableTreeNode actualElement = e.nextElement();
				if (actualElement.isLeaf() == true && key.isEmpty() == false && actualElement.toString().toLowerCase().contains(key.toLowerCase()) == false) {
					//--- immediate removal invalidates the enumeration ---
	//				actualElement.removeFromParent();
					// --- remember for later removal ---
					toDeleteVect.add(actualElement); 
				}
				if(actualElement.isLeaf() == true && actualElement.toString().toLowerCase().contains(key.toLowerCase()) == true){
					//--- (re)expand collapsed parent if search string matches ---
					int level = actualElement.getLevel() -1;
					StringBuilder sb = new StringBuilder();
					sb.append(level -1).append(",");
					String levelString = sb.toString();
					if(expansionState.contains(levelString) == false){
						levelString = sb.append(level).append(",").toString();
						expansionState = expansionState.concat(levelString);
					}
				}
			}
		}
		//--- delete nodes ---
		for( int i=0; i < toDeleteVect.size(); i++){
			toDeleteVect.get(i).removeFromParent();
		}
	}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:40,代码来源:ThreadInfoStorageTree.java

示例2: sortThreads

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
public void sortThreads() {
	DefaultMutableTreeNode tempNode = (DefaultMutableTreeNode) copyNode((DefaultMutableTreeNode) getModel().getRoot());

	// --- save expansion state ---
	expansionState = saveExpansionState();

	// --- sort and update ---
	@SuppressWarnings("rawtypes")
	Enumeration e = tempNode.breadthFirstEnumeration();
	while (e.hasMoreElements()) {
		DefaultMutableTreeNode node = (DefaultMutableTreeNode) e.nextElement();
		if (node.isLeaf() == true) {
			sortNodesDescending((DefaultMutableTreeNode) node.getParent(),
					(DefaultTreeModel) getModel());
		}
	}

	((DefaultTreeModel) getModel()).setRoot(tempNode);

	// --- restore expansion ---
	restoreExpansionState(expansionState);
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:23,代码来源:ThreadInfoStorageTree.java

示例3: pathExists

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
private DefaultMutableTreeNode pathExists(DefaultMutableTreeNode parent, String path) {
    if (parent == null) {
        parent = rootNode;
    }
    for (Enumeration node = parent.breadthFirstEnumeration(); node.hasMoreElements(); ) {
        DefaultMutableTreeNode child = (DefaultMutableTreeNode) node.nextElement();
        PwnBackNode usrNode = (PwnBackNode) child.getUserObject();
        if (usrNode.getPath().equals(path)) {
            return child;
        }
    }
    return null;
}
 
开发者ID:k4ch0w,项目名称:PwnBack,代码行数:14,代码来源:PwnBackWebTree.java

示例4: expandTree

import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
private void expandTree(JTree tree) {
    DefaultMutableTreeNode root = (DefaultMutableTreeNode) tree.getModel()
            .getRoot();
    Enumeration e = root.breadthFirstEnumeration();
    while (e.hasMoreElements()) {
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) e.nextElement();
        if (node.isLeaf()) {
            continue;
        }
        int row = tree.getRowForPath(new TreePath(node.getPath()));
        tree.expandRow(row);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:LastNodeLowerHalfDrop.java


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