javajavafxjavafx-tableview

How to SELECT specific table index in JAVAFX TABLEVIEW


I want to select specific index in my e.g tableview.index(0).getSelectedItem(); something like this. I did it but I can only select the last row. something like selectLast(); quiet similar to what I wanna do. How to do that in javafx, I'm quiet beginner to this language hopefully I did point out what I'm trying to say.


Solution

  • tableView.getSelectionModel().select(index);
    

    The above code will select the index you wish to select.

    tableView.getSelectionModel().getSelectedItem();
    

    And the above code will return you the item at the index.