Alberto Amat Alvarez
Alberto Amat Alvarez

Reputation: 95

Javafx: Count the number of selected rows in a TableView using bind property

I want to disable a button when the number of selected rows in a tableview is different from 1 using bind property. Is possible? Thanks and sorry for my english

Upvotes: 2

Views: 335

Answers (1)

fabian
fabian

Reputation: 82451

Use Bindings.size on the selectedIndices list of the selection model:

button.disableProperty().bind(Bindings.size(tableView.getSelectionModel().getSelectedIndices())
                                      .isNotEqualTo(1));

Upvotes: 4

Related Questions