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