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


Java JTree.expandRow方法代码示例

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


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

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

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

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

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

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

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

示例7: getTreeCellRendererComponent

import javax.swing.JTree; //导入方法依赖的package包/类
/**
 * Renderer class
 */
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value,
                                              boolean isSelected,
                                              boolean expanded,
                                              boolean leaf, int row,
                                              boolean hasFocus) {

  CorefTreeNode userObject = (CorefTreeNode) value;
  label.setText(userObject.toString());
  this.setSize(label.getWidth(),
               label.getFontMetrics(label.getFont()).getHeight() * 2);
  tree.expandRow(row);
  if (userObject.getType() == CorefTreeNode.ROOT_NODE || userObject.getType() ==
      CorefTreeNode.ANNOTSET_NODE) {
    this.setBackground(Color.white);
    this.check.setVisible(false);
    return this;
  }
  else {
    this.setBackground(currentColors.get(userObject.toString()));
    check.setVisible(true);
    check.setBackground(Color.white);
  }

  // if node should be selected
  boolean selected = currentSelections.get(userObject.toString()).
                     booleanValue();
  check.setSelected(selected);
  return this;
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:34,代码来源:CorefEditor.java

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

示例9: expandTree

import javax.swing.JTree; //导入方法依赖的package包/类
private void expandTree(JTree tree) {
    DefaultMutableTreeNode root = (DefaultMutableTreeNode) tree.getModel()
            .getRoot();
    Enumeration e = root.breadthFirstEnumeration();
    while (e.hasMoreElements()) {
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) e.nextElement();
        if (node.isLeaf()) {
            continue;
        }
        int row = tree.getRowForPath(new TreePath(node.getPath()));
        tree.expandRow(row);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:LastNodeLowerHalfDrop.java

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

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

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