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