Java Code Examples for javax.swing.JTree#expandRow()
The following examples show how to use
javax.swing.JTree#expandRow() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProjectDialog.java From quickfix-messenger with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void initComponents() { setLayout(new BorderLayout()); mainPanel = new JPanel(); mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); JScrollPane mainScrollPane = new JScrollPane(); mainScrollPane.setPreferredSize(new Dimension(300, 400)); add(mainScrollPane, BorderLayout.CENTER); projectTree = new JTree(); projectTree.setEditable(true); projectTree.setModel(new ProjectTreeModel(xmlProjectType)); projectTree.setCellRenderer(new ProjectTreeCellRenderer(frame)); projectTree.setCellEditor(new ProjectTreeCellEditor(projectTree)); projectTree.getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION); projectTree.addMouseListener(new ProjectTreeMouseListener(frame, projectTree)); projectTree.expandRow(1); mainScrollPane.getViewport().add(projectTree); pack(); }
Example 2
Source File: SelectSettlersFolderDialog.java From settlers-remake with MIT License | 6 votes |
/** * Initialize the Tree with the filesystem */ private void initTree() { RootTreeNode root = new RootTreeNode(executorService); for (File f : File.listRoots()) { root.add(new FilesystemTreeNode(f)); } model = new DefaultTreeModel(root); // to fire change event when the loading is finished root.setModel(model); tree = new JTree(model); tree.addTreeSelectionListener(selectionListener); tree.addTreeExpansionListener(expansionListener); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); tree.expandRow(0); tree.setRootVisible(false); tree.setCellRenderer(new FileTreeCellRenderer()); }
Example 3
Source File: ExplainDialogFactory.java From lucene-solr with Apache License 2.0 | 6 votes |
private JTree createExplanationTree() { DefaultMutableTreeNode top = createNode(explanation); traverse(top, explanation.getDetails()); JTree tree = new JTree(top); tree.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer(); renderer.setOpenIcon(null); renderer.setClosedIcon(null); renderer.setLeafIcon(null); tree.setCellRenderer(renderer); // expand all nodes for (int row = 0; row < tree.getRowCount(); row++) { tree.expandRow(row); } return tree; }
Example 4
Source File: LastNodeLowerHalfDrop.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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); } }
Example 5
Source File: VisualProfiler.java From diirt with MIT License | 5 votes |
private void initComponents(){ treeRoot = new DefaultMutableTreeNode(new File(ProfileGraph2D.LOG_FILEPATH)); treeModel = new DefaultTreeModel(treeRoot); tree = new JTree(treeRoot){ @Override public String convertValueToText(Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus){ DefaultMutableTreeNode node = (DefaultMutableTreeNode) value; try{ File f = (File) node.getUserObject(); return f.getName(); } catch(Exception e){ return node.toString(); } } }; tree .setModel(treeModel); tree .expandRow(0); tree .setShowsRootHandles(true); btnOpenFiles = new JButton("Open File(s)"); actionButtons .add(btnOpenFiles); btnDeleteFiles = new JButton("Delete File(s)"); actionButtons .add(btnDeleteFiles); btnReloadFiles = new JButton("Refresh"); actionButtons .add(btnReloadFiles); }
Example 6
Source File: TreeHelpers.java From binnavi with Apache License 2.0 | 5 votes |
public static void restoreExpansionState(final JTree tree, final int row, final String expansionState) { final StringTokenizer stok = new StringTokenizer(expansionState, ","); while (stok.hasMoreTokens()) { final int token = row + Integer.parseInt(stok.nextToken()); tree.expandRow(token); } }
Example 7
Source File: CommunityDialog.java From WorldGrower with GNU General Public License v3.0 | 5 votes |
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()); } }
Example 8
Source File: MainFrameTree.java From spotbugs with GNU Lesser General Public License v2.1 | 5 votes |
@SwingThread void expandTree(int max) { Debug.printf("expandTree(%d)\n", max); JTree jTree = getTree(); int i = 0; while (true) { int rows = jTree.getRowCount(); if (i >= rows || rows >= max) { break; } jTree.expandRow(i++); } }
Example 9
Source File: TDA.java From tda with GNU Lesser General Public License v2.1 | 5 votes |
/** * expand all nodes of the currently selected category, only works for tree categories. */ private void expandAllCatNodes(boolean expand) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); JTree catTree = (JTree) ((TreeCategory) node.getUserObject()).getCatComponent(this); if(expand) { for (int i = 0; i < catTree.getRowCount(); i++) { catTree.expandRow(i); } } else { for (int i = 0; i < catTree.getRowCount(); i++) { catTree.collapseRow(i); } } }
Example 10
Source File: WorkingMemoryPanel.java From cst with GNU Lesser General Public License v3.0 | 5 votes |
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()); } }
Example 11
Source File: CompanionInfoTab.java From pcgen with GNU Lesser General Public License v2.1 | 5 votes |
private void selectCompanion(CompanionFacade compFacade) { TreeTableModel treeTableModel = companionsTable.getTreeTableModel(); treeTableModel.getRoot(); TreePath path = null; JTree tree = companionsTable.getTree(); String companionType = compFacade.getCompanionType(); for (int i = 0; i < tree.getRowCount(); i++) { TreePath pathForRow = tree.getPathForRow(i); Object lastPathComponent = pathForRow.getLastPathComponent(); if (lastPathComponent.toString().startsWith(companionType)) { tree.expandRow(i); } else if (lastPathComponent instanceof pcgen.gui2.tabs.CompanionInfoTab.CompanionsModel.CompanionNode) { CompanionFacade rowComp = (CompanionFacade) ((pcgen.gui2.tabs.CompanionInfoTab.CompanionsModel.CompanionNode) lastPathComponent) .getValueAt(0); if (rowComp != null && rowComp.getFileRef().get() == compFacade.getFileRef().get() && rowComp.getNameRef().get() == compFacade.getNameRef().get() && rowComp.getRaceRef().get() == compFacade.getRaceRef().get()) { path = pathForRow; } } } if (path != null) { companionsTable.getTree().setSelectionPath(path); companionsTable.getTree().scrollPathToVisible(path); } }
Example 12
Source File: TreeManager.java From cst with GNU Lesser General Public License v3.0 | 5 votes |
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()); } }
Example 13
Source File: TreeExpansionUtil.java From CQL with GNU Affero General Public License v3.0 | 5 votes |
/** * * * @param tree * @param row * @param expansionState */ public static void restoreExpansionState(JTree tree, int row, String expansionState) { StringTokenizer stok = new StringTokenizer(expansionState, ","); while (stok.hasMoreTokens()) { int token = row + Integer.parseInt(stok.nextToken()); tree.expandRow(token); } }
Example 14
Source File: CorefEditor.java From gate-core with GNU Lesser General Public License v3.0 | 5 votes |
/** * 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; }
Example 15
Source File: GeopaparazziController.java From hortonmachine with GNU General Public License v3.0 | 5 votes |
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()); } }
Example 16
Source File: EquipInfoTab.java From pcgen with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void actionPerformed(ActionEvent e) { JTree tree = equipmentSetTable.getTree(); for (int i = 0; i < tree.getRowCount(); i++) { tree.expandRow(i); } }
Example 17
Source File: AbilityChooserTab.java From pcgen with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void actionPerformed(ActionEvent e) { if (!abilityCat.isEditable()) { return; } Object data = availableTreeViewPanel.getSelectedObject(); int index = categoryTable.getSelectedRow(); if (data != null && data instanceof AbilityFacade && index != -1) { AbilityCategory category = (AbilityCategory) categoryTable.getValueAt(index, 0); character.addAbility(category, (AbilityFacade) data); availableTreeViewPanel.refilter(); JTree tree = selectedTreeViewPanel.getTree(); for (int i = 0; i < tree.getRowCount(); i++) { TreePath pathForRow = tree.getPathForRow(i); if (category.toString().equals(pathForRow.getLastPathComponent().toString())) { tree.expandRow(i); } } } }
Example 18
Source File: SpatialtoolboxController.java From hortonmachine with GNU General Public License v3.0 | 5 votes |
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()); } }
Example 19
Source File: AbilityChooserTab.java From pcgen with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void actionPerformed(ActionEvent e) { if (!abilityCat.isEditable()) { return; } Object data = availableTreeViewPanel.getSelectedObject(); int index = categoryTable.getSelectedRow(); if (data != null && data instanceof AbilityFacade && index != -1) { AbilityCategory category = (AbilityCategory) categoryTable.getValueAt(index, 0); character.addAbility(category, (AbilityFacade) data); availableTreeViewPanel.refilter(); JTree tree = selectedTreeViewPanel.getTree(); for (int i = 0; i < tree.getRowCount(); i++) { TreePath pathForRow = tree.getPathForRow(i); if (category.toString().equals(pathForRow.getLastPathComponent().toString())) { tree.expandRow(i); } } } }
Example 20
Source File: ProcessingComponent.java From mzmine2 with GNU General Public License v2.0 | 4 votes |
private void expandAllNodes(@Nonnull JTree tree) { for (int i = 0; i < tree.getRowCount(); i++) { tree.expandRow(i); } }