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


Java TreeNode.getIndex方法代碼示例

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


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

示例1: 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

示例2: 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

示例3: canMoveUp

import javax.swing.tree.TreeNode; //導入方法依賴的package包/類
@Override
public boolean canMoveUp(GenericTreeModel<T> model, T node)
{
	TreeNode parent = node.getParent();
	if( parent == null )
	{
		return false;
	}
	else
	{
		int index = parent.getIndex(node);
		return index > 0 || parent.getParent() != null;
	}
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:15,代碼來源:GenericTreeModel.java

示例4: canMoveDown

import javax.swing.tree.TreeNode; //導入方法依賴的package包/類
@Override
public boolean canMoveDown(GenericTreeModel<T> model, T node)
{
	TreeNode parent = node.getParent();
	if( parent == null )
	{
		return false;
	}
	else
	{
		int index = parent.getIndex(node);
		return index < parent.getChildCount() - 1 || parent.getParent() != null;
	}
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:15,代碼來源:GenericTreeModel.java

示例5: treeContains

import javax.swing.tree.TreeNode; //導入方法依賴的package包/類
private boolean treeContains(TreeNode root, TreeNode node) {
    if (root.getIndex(node) != -1) {
        return true;
    }

    for (int i = 0; i < root.getChildCount(); i++) {
        if (treeContains(root.getChildAt(i), node)) {
            return true;
        }
    }

    return false;
}
 
開發者ID:bcgov,項目名稱:sbc-qsystem,代碼行數:14,代碼來源:JTreeComboBox.java


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