Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaFX setting selection in a TableView

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?

like image 536
Chromos Avatar asked Jan 15 '13 13:01

Chromos


People also ask

How to select a row in TableView JavaFX?

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);


1 Answers

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.

like image 116
Uluk Biy Avatar answered Oct 15 '22 01:10

Uluk Biy