List of usage examples for javafx.scene.control SelectionModel getSelectedIndex
public final int getSelectedIndex()
Returns the integer value indicating the currently selected index in this model.
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); }// w w w .j a va 2s. c o m selectedTreeItem = found; astTreeView.getFocusModel().focus(selectionModel.getSelectedIndex()); if (!treeViewWrapper.isIndexVisible(selectionModel.getSelectedIndex())) { astTreeView.scrollTo(selectionModel.getSelectedIndex()); } } }