private Optional<Account> getSelectedAccount() { final TreeItem<Account> treeItem = treeTableView.getSelectionModel().getSelectedItem(); if (treeItem != null) { return Optional.ofNullable(treeItem.getValue()); } return Optional.empty(); }
@Override public void start(Stage primaryStage) { primaryStage.setTitle("TreeTable View Sample"); primaryStage.setScene(new Scene(new ChoiceBoxTreeTableSample())); primaryStage.sizeToScene(); primaryStage.show(); TreeTableView<?> treeTableView = (TreeTableView<?>) primaryStage.getScene().getRoot().lookup(".tree-table-view"); treeTableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); }
private void installListeners() { treeTableView .getSelectionModel() .selectedItemProperty() .addListener( (observable, oldValue, newValue) -> { if (newValue != null) { selectedAccountProperty.setValue(newValue.getValue()); } else { selectedAccountProperty.setValue(null); } }); for (final TreeTableColumn<?, ?> treeTableColumn : treeTableView.getColumns()) { treeTableColumn .visibleProperty() .addListener((observable, oldValue, newValue) -> saveColumnVisibility()); } }