List of usage examples for javafx.scene.control SelectionModel select
public abstract void select(T obj);
This method will attempt to select the index that contains the given object.
From source file:net.sourceforge.pmd.util.fxdesigner.SourceEditorController.java
public void focusNodeInTreeView(Node node) { SelectionModel<TreeItem<Node>> selectionModel = astTreeView.getSelectionModel(); // node is different from the old one if (selectedTreeItem == null && node != null || selectedTreeItem != null && !Objects.equals(node, selectedTreeItem.getValue())) { ASTTreeItem found = ((ASTTreeItem) astTreeView.getRoot()).findItem(node); if (found != null) { selectionModel.select(found); }//from ww w .j av a2s . co m selectedTreeItem = found; astTreeView.getFocusModel().focus(selectionModel.getSelectedIndex()); if (!treeViewWrapper.isIndexVisible(selectionModel.getSelectedIndex())) { astTreeView.scrollTo(selectionModel.getSelectedIndex()); } } }