當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。