List of usage examples for javax.swing JTree getRowCount
@BeanProperty(bound = false) public int getRowCount()
From source file:pcgen.gui2.tabs.CompanionInfoTab.java
private void selectCompanion(CompanionFacade compFacade) { TreeTableModel treeTableModel = companionsTable.getTreeTableModel(); treeTableModel.getRoot();/*from w w w.j a v a 2s . c om*/ 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); } }