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


Java TreeModel.getChild方法代碼示例

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


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

示例1: expandAllPaths

import javax.swing.tree.TreeModel; //導入方法依賴的package包/類
/**
 * Opens all paths in the given node and all nodes below that.
 *
 * @param path
 *            the tree path to the node to expand
 * @param treeModel
 *            the tree model
 * @see JTree#expandPath(TreePath)
 */
protected void expandAllPaths(TreePath path, TreeModel treeModel) {
	expandPath(path);
	final Object node = path.getLastPathComponent();
	final int n = treeModel.getChildCount(node);
	for (int index = 0; index < n; index++) {
		final Object child = treeModel.getChild(node, index);
		expandAllPaths(path.pathByAddingChild(child));
	}
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:19,代碼來源:PlotConfigurationTree.java

示例2: SelectionTreeItemListener

import javax.swing.tree.TreeModel; //導入方法依賴的package包/類
public SelectionTreeItemListener(SelectionPanel owner) {
	if (owner == null)
		throw new IllegalArgumentException();
	this.owner = owner;

	TreeModel model = owner.getTree().getModel();
	Object root = owner.getTree().getModel().getRoot();

	ePath = new TreePath(new Object[] { root, model.getChild(root, 0) });
	vPath = new TreePath(new Object[] { root, model.getChild(root, 1) });
}
 
開發者ID:KeepTheBeats,項目名稱:alevin-svn2,代碼行數:12,代碼來源:SelectionTreeItemListener.java

示例3: getSimilarPath

import javax.swing.tree.TreeModel; //導入方法依賴的package包/類
private TreePath getSimilarPath(TreePath oldPath) {
    if (oldPath == null || oldPath.getPathCount() < 1) return null;

    TreeModel currentModel = getModel();
    Object currentRoot = currentModel.getRoot();
    if (!currentRoot.equals(oldPath.getPathComponent(0))) return null;

    TreePath p = new TreePath(currentRoot);
    Object[] op = oldPath.getPath();
    Object n = currentRoot;

    for (int i = 1; i < op.length; i++) {
        Object nn = null;

        for (int ii = 0; ii < currentModel.getChildCount(n); ii++) {
            Object c = currentModel.getChild(n, ii);
            if (c.equals(op[i])) {
                nn = c;
                break;
            }
        }

        if (nn == null) return null;

        n = nn;
        p = p.pathByAddingChild(n);
    }

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

示例4: setCurrentSubcategory

import javax.swing.tree.TreeModel; //導入方法依賴的package包/類
void setCurrentSubcategory(String subpath) {
    TreeModel mdl = errorTree.getModel();
    for (int i = 0; i < mdl.getChildCount(mdl.getRoot()); i++) {
        Object child = mdl.getChild(mdl.getRoot(), i);
        Object data = ((DefaultMutableTreeNode) child).getUserObject();
        if (data instanceof POMErrorFixBase) {
            POMErrorFixBase rule = (POMErrorFixBase) data;
            if (rule.getConfiguration().getId().equals(subpath)) {
                errorTree.setSelectionRow(i);
                break;
            }
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:15,代碼來源:HintsPanel.java

示例5: getChildren

import javax.swing.tree.TreeModel; //導入方法依賴的package包/類
private ArrayList<String> getChildren(TreeModel tree, Object root, String spaces) {
    int categoriesCount = tree.getChildCount(root);
    ArrayList<String> returnList = new ArrayList<String>();
    for (int i = 0; i <= categoriesCount - 1; i++) {
        Object actualChild = tree.getChild(root, i);
        returnList.add(spaces + actualChild.toString());

        if (!tree.isLeaf(actualChild)) {
            spaces = "+-" + spaces;
            returnList.addAll(getChildren(tree, actualChild, spaces));
            spaces = spaces.substring(2);
        }
    }
    return returnList;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:16,代碼來源:NewProjectTest.java

示例6: getPath

import javax.swing.tree.TreeModel; //導入方法依賴的package包/類
private TreePath getPath(JTree tree, String path) {
    String[] tokens = path.substring(1).split("(?<!\\\\)/");
    TreeModel treeModel = tree.getModel();
    if (treeModel == null) {
        throw new RuntimeException("Could not find model for tree");
    }
    Object rootNode = treeModel.getRoot();
    int start = tree.isRootVisible() ? 1 : 0;
    TreePath treePath = new TreePath(rootNode);
    StringBuilder searchedPath = new StringBuilder();
    if (tree.isRootVisible()) {
        String rootNodeText = unescapeSpecialCharacters(tokens[0]);
        searchedPath.append("/" + rootNodeText);
        assertTrue("JTree does not have a root node!", rootNode != null);
        assertTrue("JTree root node does not match: Expected </" + getPathText(tree, treePath) + "> Actual: <"
                + searchedPath.toString() + ">", searchedPath.toString().equals("/" + getPathText(tree, treePath)));
    }
    for (int i = start; i < tokens.length; i++) {
        String childText = unescapeSpecialCharacters(tokens[i]);
        searchedPath.append("/" + childText);
        boolean matched = false;
        tree.expandPath(treePath);
        for (int j = 0; j < treeModel.getChildCount(treePath.getLastPathComponent()); j++) {
            Object child = treeModel.getChild(treePath.getLastPathComponent(), j);
            TreePath childPath = treePath.pathByAddingChild(child);
            if (childText.equals(getPathText(tree, childPath))) {
                treePath = childPath;
                matched = true;
                break;
            }
        }
        if (!matched) {
            return null;
        }
    }
    return treePath;
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:38,代碼來源:JTreeJavaElement.java

示例7: getNodeCount

import javax.swing.tree.TreeModel; //導入方法依賴的package包/類
private static int getNodeCount(TreeModel model, Object root) {
    int count = model.getChildCount(root);
    for (int i = 0; i < model.getChildCount(root); i++) {
        Object node = model.getChild(root, i);
        count += getNodeCount(model, node);
    }
    return count;
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:9,代碼來源:JTreeJavaElement.java


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