How do I set a selection in a TableView? I want the first index selected by default.
productTable.selectionModelProperty().set(value);
Is this right? What should value
be?
To select a row with a specific index you can use the select(int) method. Here is an example of selecting a single row with a given index in a JavaFX TableView: selectionModel. select(1);
The TableViewSelectionModel
provides various methods of selections:
productTable.getSelectionModel().selectFirst();
Even the default value should be selected by someone in somewhere. In your case, it is you ;), running above code in some init block.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With