当前位置: 首页>>代码示例>>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;未经允许,请勿转载。