當前位置: 首頁>>代碼示例>>Java>>正文


Java TreeNode.getChildAt方法代碼示例

本文整理匯總了Java中javax.swing.tree.TreeNode.getChildAt方法的典型用法代碼示例。如果您正苦於以下問題:Java TreeNode.getChildAt方法的具體用法?Java TreeNode.getChildAt怎麽用?Java TreeNode.getChildAt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.tree.TreeNode的用法示例。


在下文中一共展示了TreeNode.getChildAt方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testLazyVisDestroy

import javax.swing.tree.TreeNode; //導入方法依賴的package包/類
public void testLazyVisDestroy() throws Exception {
    LazyChildren lch = new LazyChildren();
    AbstractNode a = new AbstractNode(lch);
    List<String> arr = Collections.nCopies(100, "A");
    lch.keys(arr.toArray(new String[0]));

    TreeNode ta = Visualizer.findVisualizer(a);
    final TreeNode snd = ta.getChildAt(2);

    Reference<Node> sndNode = new WeakReference<Node>(Visualizer.findNode(snd));

    assertEquals("Child check", "A", snd.toString());
    assertEquals("Counter should be 1", 1, lch.cnt);

    a.destroy();

    assertGC("Whole subtree under a can be GCed now", sndNode);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:19,代碼來源:VisualizerNodeTest.java

示例2: testLazyFilterGet

import javax.swing.tree.TreeNode; //導入方法依賴的package包/類
public void testLazyFilterGet() throws Exception {
    LazyChildren lch = new LazyChildren();
    AbstractNode a = new AbstractNode(lch);
    FilterNode fnode = new FilterNode(a);
    
    TreeNode ta = Visualizer.findVisualizer(fnode);
    
    assertEquals("Child check", "c", ta.getChildAt(2).toString());
    assertEquals("Counter should be 1", 1, lch.cnt);

    VisualizerNode vn = (VisualizerNode)ta.getChildAt(2);
    String msg = ((VisualizerNode)ta).getChildren().dumpIndexes(vn);
    if (msg.indexOf("'c'") == -1) {
        fail("Missing note about visualizer node 'c': " + msg);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:17,代碼來源:VisualizerNodeTest.java

示例3: areSiblingsFullyChecked

import javax.swing.tree.TreeNode; //導入方法依賴的package包/類
private boolean areSiblingsFullyChecked() {
    TreeNode parent = getParent();

    for (int i = 0; i < parent.getChildCount(); i++) {
        TreeNode node = parent.getChildAt(i);

        if (node == this) {
            continue;
        }

        if (!(node instanceof CheckTreeNode) || (((CheckTreeNode) node).getCheckState() != STATE_CHECKED)) {
            return false;
        }
    }

    return true;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:18,代碼來源:CheckTreeNode.java

示例4: areSiblingsUnchecked

import javax.swing.tree.TreeNode; //導入方法依賴的package包/類
private boolean areSiblingsUnchecked() {
    TreeNode parent = getParent();

    for (int i = 0; i < parent.getChildCount(); i++) {
        TreeNode node = parent.getChildAt(i);

        if (node == this) {
            continue;
        }

        if (!(node instanceof CheckTreeNode) || (((CheckTreeNode) node).getCheckState() != STATE_UNCHECKED)) {
            return false;
        }
    }

    return true;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:18,代碼來源:CheckTreeNode.java

示例5: find

import javax.swing.tree.TreeNode; //導入方法依賴的package包/類
/**
 * Retrieves the child of a given parent node that is
 * a numbered tree node with a given number, if any.
 * @return the correctly numbered child, or {@code null} if there
 * is none such
 */
private NumberedTreeNode find(TreeNode parent, int number) {
    NumberedTreeNode result = null;
    int lower = 0;
    int upper = parent.getChildCount() - 1;
    boolean found = false;
    while (!found && lower <= upper) {
        int mid = (lower + upper) / 2;
        result = (NumberedTreeNode) parent.getChildAt(mid);
        int resultNumber = result.getNumber();
        if (result.contains(number)) {
            found = true;
        } else if (resultNumber < number) {
            lower = mid + 1;
        } else if (resultNumber > number) {
            upper = mid - 1;
        }
    }
    return found ? result : null;
}
 
開發者ID:meteoorkip,項目名稱:JavaGraph,代碼行數:26,代碼來源:StateTree.java

示例6: execute

import javax.swing.tree.TreeNode; //導入方法依賴的package包/類
@Override
public void execute() {
    TreeNode root = (TreeNode) this.tree.getModel().getRoot();
    List<DefaultMutableTreeNode> collapsableNodes = new ArrayList<>();
    for (int i = 0; i < root.getChildCount(); i++) {
        TreeNode child = root.getChildAt(i);
        if (isDirectoryNode(child)) {
            for (int j = 0; j < child.getChildCount(); j++) {
                collapsableNodes.add((DefaultMutableTreeNode) child.getChildAt(j));
            }
        } else {
            collapsableNodes.add((DefaultMutableTreeNode) child);
        }
    }
    for (DefaultMutableTreeNode node : collapsableNodes) {
        TreePath path = new TreePath(node.getPath());
        if (!this.tree.isCollapsed(path)) {
            this.tree.collapsePath(path);
        }
    }
}
 
開發者ID:meteoorkip,項目名稱:JavaGraph,代碼行數:22,代碼來源:CollapseAllAction.java

示例7: treeExpanded

import javax.swing.tree.TreeNode; //導入方法依賴的package包/類
@Override
public void treeExpanded(final TreeExpansionEvent event) {
	final TreePath treePath = event.getPath();

	final Object expandedTreePathObject = treePath.getLastPathComponent();
	if (!(expandedTreePathObject instanceof TreeNode)) {
		return;
	}

	final TreeNode expandedTreeNode = (TreeNode) expandedTreePathObject;
	if (expandedTreeNode.getChildCount() == 1) {
		final TreeNode descendantTreeNode = expandedTreeNode.getChildAt(0);

		if (descendantTreeNode.isLeaf()) {
			return;
		}

		final TreePath nextTreePath = treePath.pathByAddingChild(descendantTreeNode);
		tree.expandPath(nextTreePath);
	}
}
 
開發者ID:KevinPriv,項目名稱:Luyten4Forge,代碼行數:22,代碼來源:Model.java

示例8: getChildAfter

import javax.swing.tree.TreeNode; //導入方法依賴的package包/類
/**
 * Returns the child in this node's child array that immediately follows
 * <code>aChild</code>, which must be a child of this node. If
 * <code>aChild</code> is the last child, returns null. This method performs
 * a linear search of this node's children for <code>aChild</code> and is
 * O(n) where n is the number of children; to traverse the entire array of
 * children, use an enumeration instead.
 *
 * @param parent
 * @param aChild
 * @see #children
 * @exception IllegalArgumentException if <code>aChild</code> is null or is
 * not a child of this node
 * @return the child of this node that immediately follows
 * <code>aChild</code>
 */
public TreeNode getChildAfter(TreeNode parent, TreeNode aChild) {
    if (aChild == null) {
        throw new IllegalArgumentException("argument is null");
    }

    int index = parent.getIndex(aChild);           // linear search

    if (index == -1) {
        throw new IllegalArgumentException("node is not a child");
    }

    if (index < parent.getChildCount() - 1) {
        return parent.getChildAt(index + 1);
    } else {
        return null;
    }
}
 
開發者ID:CognizantQAHub,項目名稱:Cognizant-Intelligent-Test-Scripter,代碼行數:34,代碼來源:TreeSearch.java

示例9: getChildBefore

import javax.swing.tree.TreeNode; //導入方法依賴的package包/類
/**
 * Returns the child in this node's child array that immediately precedes
 * <code>aChild</code>, which must be a child of this node. If
 * <code>aChild</code> is the first child, returns null. This method
 * performs a linear search of this node's children for <code>aChild</code>
 * and is O(n) where n is the number of children.
 *
 * @param parent
 * @param aChild
 * @exception IllegalArgumentException if <code>aChild</code> is null or is
 * not a child of this node
 * @return the child of this node that immediately precedes
 * <code>aChild</code>
 */
public TreeNode getChildBefore(TreeNode parent, TreeNode aChild) {
    if (aChild == null) {
        throw new IllegalArgumentException("argument is null");
    }

    int index = parent.getIndex(aChild);           // linear search

    if (index == -1) {
        throw new IllegalArgumentException("argument is not a child");
    }

    if (index > 0) {
        return parent.getChildAt(index - 1);
    } else {
        return null;
    }
}
 
開發者ID:CognizantQAHub,項目名稱:Cognizant-Intelligent-Test-Scripter,代碼行數:32,代碼來源:TreeSearch.java

示例10: getSelectedNodes

import javax.swing.tree.TreeNode; //導入方法依賴的package包/類
private List<StoreEntryNode> getSelectedNodes(TreeNode node) {
    List<StoreEntryNode> ret = new LinkedList<StoreEntryNode>();
    int count = node.getChildCount();
    for (int i = 0; i < count; i++) {
        TreeNode child = node.getChildAt(i);
        if(child instanceof StoreEntryNode) {
            StoreEntryNode sen = (StoreEntryNode) child;
            if(sen.isSelected()) {
                ret.add(sen);
            }
        }
        ret.addAll(getSelectedNodes(child));
    }
    return ret;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:16,代碼來源:RevertDeletedAction.java

示例11: getPosition

import javax.swing.tree.TreeNode; //導入方法依賴的package包/類
private static String getPosition(AndroidTreeNode node) {
    int count = 0;
    TreeNode parent = node.getParent();
    String nodeName = node.getClassName();
    for (int i = 0; i < parent.getChildCount(); i++) {
        AndroidTreeNode currNode = (AndroidTreeNode) parent.getChildAt(i);
        if (currNode.getClassName().equals(nodeName)) {
            count++;
            if (currNode.equals(node)) {
                return nodeName + "[" + count + "]";
            }
        }
    }
    return nodeName;
}
 
開發者ID:CognizantQAHub,項目名稱:Cognizant-Intelligent-Test-Scripter,代碼行數:16,代碼來源:XpathGenerator.java

示例12: addContributedGrids

import javax.swing.tree.TreeNode; //導入方法依賴的package包/類
private void addContributedGrids(Map<String, Rectangle2D.Double> namesToBounds, TreeNode root) {
	if (root.isLeaf())
		addContributedGrid(namesToBounds, root);
	else
		for (int i = 0; i < root.getChildCount(); i++) {
			TreeNode node = root.getChildAt(i);
			addContributedGrids(namesToBounds, node);
		}
}
 
開發者ID:iedadata,項目名稱:geomapapp,代碼行數:10,代碼來源:ContributedGridsOverlay.java

示例13: getChildAt

import javax.swing.tree.TreeNode; //導入方法依賴的package包/類
public TreeNode getChildAt(TreeNode parent, int index) {
    return parent.getChildAt(index);
}
 
開發者ID:CognizantQAHub,項目名稱:Cognizant-Intelligent-Test-Scripter,代碼行數:4,代碼來源:JCheckBoxTree.java

示例14: getLastChild

import javax.swing.tree.TreeNode; //導入方法依賴的package包/類
/**
 * Returns this node's last child. If this node has no children, throws
 * NoSuchElementException.
 *
 * @param node
 * @return the last child of this node
 */
public TreeNode getLastChild(TreeNode node) {
    if (node.getChildCount() == 0) {
        throw new Error("node has no children");
    }
    return node.getChildAt(node.getChildCount() - 1);
}
 
開發者ID:CognizantQAHub,項目名稱:Cognizant-Intelligent-Test-Scripter,代碼行數:14,代碼來源:TreeSearch.java


注:本文中的javax.swing.tree.TreeNode.getChildAt方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。