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


Java JTree.isRootVisible方法代码示例

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


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

示例1: getTextForNode

import javax.swing.JTree; //导入方法依赖的package包/类
private String getTextForNode(JTree tree, int row) {
    TreePath treePath = tree.getPathForRow(row);
    if (treePath == null) {
        return row + "";
    }
    StringBuilder sb = new StringBuilder();
    int start = tree.isRootVisible() ? 0 : 1;
    Object[] objs = treePath.getPath();
    for (int i = start; i < objs.length; i++) {
        String pathString;
        if (objs[i].toString() == null) {
            pathString = "";
        } else {
            pathString = escapeSpecialCharacters(getTextForNodeObject(tree, objs[i]));
        }
        sb.append("/" + pathString);
    }
    return sb.toString();
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:20,代码来源:RTree.java

示例2: getPath

import javax.swing.JTree; //导入方法依赖的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

示例3: closeAllPaths

import javax.swing.JTree; //导入方法依赖的package包/类
public void closeAllPaths(JTree tree) {
	TreePath pathToRoot = new TreePath(tree.getModel().getRoot());
	closePaths(tree, pathToRoot);
	if (!tree.isRootVisible())
		tree.expandPath(pathToRoot);
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:7,代码来源:MapPlaces.java

示例4: closeAllPaths

import javax.swing.JTree; //导入方法依赖的package包/类
public static void closeAllPaths(JTree tree) {
	TreePath pathToRoot = new TreePath(tree.getModel().getRoot());
	closePaths(tree, pathToRoot);
	if (!tree.isRootVisible())
		tree.expandPath(pathToRoot);
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:7,代码来源:XML_Menu.java


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