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


Java TreeNode.isLeaf方法代码示例

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


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

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

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

示例3: findString

import javax.swing.tree.TreeNode; //导入方法依赖的package包/类
public static boolean findString(ProfilerTable table, String text, boolean matchCase, boolean next) {
    int rowCount = table.getRowCount();
    
    ProfilerTreeTable treeTable = null;
    
    if (rowCount == 0) {
        ProfilerDialogs.displayWarning(MSG_NODATA, ACTION_FIND, null);
        return false;
    } else if (rowCount == 1) {
        if (!(table instanceof ProfilerTreeTable)) return false;
        
        treeTable = (ProfilerTreeTable)table;
        TreeNode node = treeTable.getValueForRow(0);
        if (node == null || node.isLeaf()) return false;
    }
    
    if (treeTable != null || table instanceof ProfilerTreeTable) {
        if (treeTable == null) treeTable = (ProfilerTreeTable)table;
        return findString(treeTable, text, matchCase, next, null);
    } else {
        table.putClientProperty(LAST_FIND_TEXT, text);
        table.putClientProperty(LAST_FIND_MATCH_CASE, matchCase);
        
        if (!matchCase) text = text.toLowerCase();
        
        int mainColumn = table.convertColumnIndexToView(table.getMainColumn());
    
        int selectedRow = table.getSelectedRow();
        boolean fromSelection = selectedRow != -1;
    
        if (!fromSelection) selectedRow = next ? 0 : rowCount - 1;
        else selectedRow = next ? table.getNextRow(selectedRow) :
                                  table.getPreviousRow(selectedRow);
    
        int searchSteps = fromSelection ? rowCount - 1 : rowCount;
        for (int i = 0; i < searchSteps; i++) {
            String value = table.getStringValue(selectedRow, mainColumn);
            if (!matchCase) value = value.toLowerCase();
            if (value.contains(text)) {
                table.selectRow(selectedRow, true);
                return true;
            }
            selectedRow = next ? table.getNextRow(selectedRow) :
                                 table.getPreviousRow(selectedRow);
        }
        
        ProfilerDialogs.displayInfo(MSG_NOTFOUND, ACTION_FIND, null);
        return false;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:51,代码来源:SearchUtils.java

示例4: getLastLeaf

import javax.swing.tree.TreeNode; //导入方法依赖的package包/类
/**
 * Finds and returns the last leaf that is a descendant of this node --
 * either this node or its last child's last leaf. Returns this node if it
 * is a leaf.
 *
 * @param node
 * @see #isLeaf
 * @see #isNodeDescendant
 * @return the last leaf in the subtree rooted at this node
 */
public TreeNode getLastLeaf(TreeNode node) {

    while (!node.isLeaf()) {
        node = getLastChild(node);
    }

    return node;
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:19,代码来源:TreeSearch.java


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