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


Java JTree.getRowCount方法代码示例

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


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

示例1: saveExpansionState

import javax.swing.JTree; //导入方法依赖的package包/类
/**
 * Saves the currently selected paths and saves all expanded repositories and nodes.
 *
 * @param tree
 *            The related tree, containing the path(s)
 */
public void saveExpansionState(JTree tree) {

	saveSelectionPaths(tree.getSelectionPaths());

	expandedNodes = new HashSet<>();
	expandedRepositories = new HashSet<>();

	for (int i = 0; i < tree.getRowCount(); i++) {
		TreePath path = tree.getPathForRow(i);
		if (tree.isExpanded(path)) {
			Entry entry = (Entry) path.getLastPathComponent();
			String absoluteLocation = entry.getLocation().getAbsoluteLocation();
			if (entry instanceof Repository) {
				expandedRepositories.add(absoluteLocation);
			} else {
				expandedNodes.add(absoluteLocation);
			}

		}
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:28,代码来源:RepositoryTreeUtil.java

示例2: restoreExpansionState

import javax.swing.JTree; //导入方法依赖的package包/类
/**
 * Expands all repositories and nodes, which have been saved before. Restores selected paths,
 * which have been saved proviously.
 *
 * @param tree
 *            The related tree, containing the path(s)
 */
public void restoreExpansionState(JTree tree) {
	for (int i = 0; i < tree.getRowCount(); i++) {
		TreePath path = tree.getPathForRow(i);
		Object entryObject = path.getLastPathComponent();
		if (entryObject instanceof Entry) {
			Entry entry = (Entry) entryObject;
			String absoluteLocation = entry.getLocation().getAbsoluteLocation();
			if (expandedRepositories.contains(absoluteLocation) || expandedNodes.contains(absoluteLocation)) {
				tree.expandPath(path);
			}
		}
	}

	restoreSelectionPaths(tree);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:23,代码来源:RepositoryTreeUtil.java

示例3: manipulateJTree

import javax.swing.JTree; //导入方法依赖的package包/类
/**
 * This method aids in the creation of the JTrees which are used to add in
 * the JTabbedPane component
 *
 * @param top
 *            - input to the JTree which will be formatted for display
 * @return JTree which will be used for adding to the root of a pane
 */
private JTree manipulateJTree(final DefaultMutableTreeNode top) {
	final JTree resultsTree = new JTree(top) {
		private static final long serialVersionUID = 1748421292182815368L;

		@Override
		public Insets getInsets() {
			return new Insets(5, 5, 5, 5);
		}
	};

	resultsTree.setRootVisible(false);
	resultsTree.setShowsRootHandles(true);

	if (resultsTree.getRowCount() > 0) {
		resultsTree.expandRow(0);
	}

	return resultsTree;
}
 
开发者ID:orionhealth,项目名称:rlc-analyser,代码行数:28,代码来源:RLCTreeBuilder.java

示例4: restoreLastExpandedPaths

import javax.swing.JTree; //导入方法依赖的package包/类
/**
 * Expand all the path from the given expandedPaths and the given tree
 * 
 * @param expandedPaths
 *          - the paths to expand
 * @param tree
 *          - the tree on which the paths has to be expanded
 */
public static void restoreLastExpandedPaths(Enumeration<TreePath> expandedPaths, JTree tree) {
	if (expandedPaths != null) {
		List<TreePath> paths = Collections.list(expandedPaths);
		for (int i = 0; i < tree.getRowCount(); i++) {
			TreePath currentPath = tree.getPathForRow(i);
			String currentStringPath = TreeFormatter.getStringPath(currentPath);
			for (TreePath treePath : paths) {
				String stringTreePahr = TreeFormatter.getStringPath(treePath);
				if (currentStringPath.equals(stringTreePahr)) {
					tree.expandRow(i);
				}
			}
		}
	}
}
 
开发者ID:oxygenxml,项目名称:oxygen-git-plugin,代码行数:24,代码来源:TreeFormatter.java

示例5: selectNextPrev

import javax.swing.JTree; //导入方法依赖的package包/类
static void selectNextPrev(final boolean next, boolean isQuery, JTree tree) {
    int[] rows = tree.getSelectionRows();
    int newRow = rows == null || rows.length == 0 ? 0 : rows[0];
    int maxcount = tree.getRowCount();
    CheckNode node;
    do {
        if (next) {
            newRow++;
            if (newRow >= maxcount) {
                newRow = 0;
            }
        } else {
            newRow--;
            if (newRow < 0) {
                newRow = maxcount - 1;
            }
        }
        TreePath path = tree.getPathForRow(newRow);
        node = (CheckNode) path.getLastPathComponent();
        if (!node.isLeaf()) {
            tree.expandRow(newRow);
            maxcount = tree.getRowCount();
        }
    } while (!node.isLeaf());
    tree.setSelectionRow(newRow);
    tree.scrollRowToVisible(newRow);
    if (isQuery) {
        CheckNodeListener.findInSource(node);
    } else {
        CheckNodeListener.openDiff(node);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:33,代码来源:CheckNodeListener.java

示例6: selectNextPrev

import javax.swing.JTree; //导入方法依赖的package包/类
static void selectNextPrev(final boolean next, boolean isQuery, JTree tree) {
    int[] rows = tree.getSelectionRows();
    int newRow = rows == null || rows.length == 0 ? 0 : rows[0];
    int maxcount = tree.getRowCount();
    CheckNode node;
    do {
        if (next) {
            newRow++;
            if (newRow >= maxcount) {
                newRow = 0;
            }
        } else {
            newRow--;
            if (newRow < 0) {
                newRow = maxcount - 1;
            }
        }
        TreePath path = tree.getPathForRow(newRow);
        node = (CheckNode) path.getLastPathComponent();
        if (!node.isLeaf()) {
            tree.expandRow(newRow);
            maxcount = tree.getRowCount();
        }
    } while (!node.isLeaf());
    tree.setSelectionRow(newRow);
    tree.scrollRowToVisible(newRow);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:CheckNodeListener.java

示例7: getJTree

import javax.swing.JTree; //导入方法依赖的package包/类
private JTree getJTree() {
    DebugTreeView treeView1 = getTreeView();
    if (treeView1 != null) {
        JTree tree = treeView1.getTree();
        if (tree != null && tree.getRowCount() > 0) {
            return tree;
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:DebuggingViewComponent.java

示例8: getExpandedPaths

import javax.swing.JTree; //导入方法依赖的package包/类
public static ArrayList<String> getExpandedPaths(JTree tree) {
    ArrayList<String> paths_expanded = new ArrayList<>();
    for(int i = 0; i < tree.getRowCount(); i++) {
        TreePath tp = tree.getPathForRow(i);
        if(tree.isExpanded(i)) {
            paths_expanded.add(tp.toString());
        }
    }
    return paths_expanded;
}
 
开发者ID:Panzer1119,项目名称:JAddOn,代码行数:11,代码来源:JTreeUtils.java

示例9: expandPaths

import javax.swing.JTree; //导入方法依赖的package包/类
public static void expandPaths(JTree tree, ArrayList<String> paths_expanded) {
    for(int i = 0; i < tree.getRowCount(); i++) {
        TreePath tp = tree.getPathForRow(i);
        if(paths_expanded.contains(tp.toString())) {
            tree.expandRow(i);
        }
    }
}
 
开发者ID:Panzer1119,项目名称:JAddOn,代码行数:9,代码来源:JTreeUtils.java

示例10: expandAllNodes

import javax.swing.JTree; //导入方法依赖的package包/类
private void expandAllNodes(JTree tree, int startingIndex, int rowCount){
    for (int i=startingIndex;i<rowCount;++i)
        tree.expandRow(i);

    if (tree.getRowCount()!=rowCount)
        expandAllNodes(tree, rowCount, tree.getRowCount());
}
 
开发者ID:adelbs,项目名称:ISO8583,代码行数:8,代码来源:PnlGuiConfig.java

示例11: expandAllNodes

import javax.swing.JTree; //导入方法依赖的package包/类
private void expandAllNodes(JTree tree, int startingIndex, int rowCount) {
	for (int i = startingIndex; i < rowCount; ++i) {
		tree.expandRow(i);
	}
	if (tree.getRowCount() != rowCount) {
		expandAllNodes(tree, rowCount, tree.getRowCount());
	}
}
 
开发者ID:Col-E,项目名称:Recaf,代码行数:9,代码来源:SearchPanel.java

示例12: createTreePane

import javax.swing.JTree; //导入方法依赖的package包/类
public JScrollPane createTreePane() { 
	// new tree
	root = new DefaultMutableTreeNode("Root");
	tree = new JTree(root);
	tree.setEditable(false);

	// click tree
	tree.addMouseListener(new MouseAdapter() {
		public void mousePressed(MouseEvent e) {
			TreePath selPath = tree.getPathForLocation(e.getX(), e.getY());
			if (selPath != null) {
				DefaultMutableTreeNode node = (DefaultMutableTreeNode) selPath.getLastPathComponent();
				if (node.isLeaf()) {

					String type = (String) node.getUserObject();
					String strpar = node.getParent().toString();
					String strcur = node.toString(); 
					 
					String selectedObjectParent = strpar;
					selectedObject = strpar +"." + strcur;
					
					if (console.wMode == HMLP_Console.windowMode.SELECT_DB){  
						console.insertTextOut("The database \"" + selectedObject +"\" was selected.");
					} else if (console.wMode == HMLP_Console.windowMode.EDIT_DB){ 
					} else if (console.wMode == HMLP_Console.windowMode.ADD_PARENTS){ 
						console.insertTextOut("The node \"" + selectedObject +"\" was selected.");
					} else if (console.wMode == windowMode.JOIN_RELATIONS) {
						
					} else if (console.wMode == HMLP_Console.windowMode.ADD_CLD){ 
						console.insertTextOut("The node \"" + selectedObject +"\" was selected.");
					} else if (console.wMode == windowMode.LEARNING) { 
					} else if (console.wMode == windowMode.EVALUATION) { 
					} 
				}
			}
		}
	});

	// Expand all
	for (int i = 0; i < tree.getRowCount(); i++)
		tree.expandRow(i);

	return new JScrollPane(tree);
}
 
开发者ID:HML-UnBBayes,项目名称:hml,代码行数:45,代码来源:TreePanel_Left.java

示例13: createTreePane

import javax.swing.JTree; //导入方法依赖的package包/类
public JScrollPane createTreePane() { 
		// new tree
		root = new DefaultMutableTreeNode("Root");
		tree = new JTree(root);
		tree.setEditable(false);
				
		// click tree
		tree.addMouseListener(new MouseAdapter() {
			public void mousePressed(MouseEvent e) {
				TreePath selPath = tree.getPathForLocation(e.getX(), e.getY());

				if (selPath != null) {
					DefaultMutableTreeNode node = (DefaultMutableTreeNode) selPath.getLastPathComponent();
					if (node.isLeaf()) {

						TreePath[] threePaths = tree.getSelectionPaths();
						
						selectedObjects.clear();
						
						for (TreePath tp: threePaths){
							DefaultMutableTreeNode eachNode = (DefaultMutableTreeNode) tp.getLastPathComponent();
							String strpar = eachNode.getParent().toString();
							String str = strpar + "." + eachNode.toString();
							selectedObjects.add(str);
						}
						
//						String type = (String) node.getUserObject();
//						String str2 = node.toString();
//						String strpar = node.getParent().toString();
						
//						selectedObject = str2;
						
						if (console.wMode == HMLP_Console.windowMode.SELECT_DB){  
							console.insertTextOut("The database \"" + selectedObjects +"\" was selected.");
						} else if (console.wMode == HMLP_Console.windowMode.EDIT_DB){ 
						} else if (console.wMode == HMLP_Console.windowMode.ADD_PARENTS){ 
							console.insertTextOut("The node \"" + selectedObjects +"\" was selected."); 
						} else if (console.wMode == windowMode.JOIN_RELATIONS) {
							
						} else if (console.wMode == HMLP_Console.windowMode.ADD_CLD){ 
							console.insertTextOut("The CLD \"" + selectedObjects +"\" was selected.");
						} else if (console.wMode == windowMode.LEARNING) { 
						} else if (console.wMode == windowMode.EVALUATION) { 
						}
					}
				}
			}
		});

		// Expand all
		for (int i = 0; i < tree.getRowCount(); i++)
			tree.expandRow(i);

		return new JScrollPane(tree);
	}
 
开发者ID:HML-UnBBayes,项目名称:hml,代码行数:56,代码来源:TreePanel_Right.java

示例14: expandAllNodes

import javax.swing.JTree; //导入方法依赖的package包/类
/**
 * Expands all the nodes from the tree
 * 
 * @param tree
 *          - tree rows to expand
 * @param startingIndex
 *          - starting row index
 * @param rowCount
 *          - end row index
 */
public static void expandAllNodes(JTree tree, int startingIndex, int rowCount) {
	for (int i = startingIndex; i < rowCount; ++i) {
		tree.expandRow(i);
	}

	if (tree.getRowCount() != rowCount) {
		expandAllNodes(tree, rowCount, tree.getRowCount());
	}
}
 
开发者ID:oxygenxml,项目名称:oxygen-git-plugin,代码行数:20,代码来源:TreeFormatter.java


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