Laugh7
Laugh7

Reputation: 187

JavaFX List View - Get currently selected item's index?

I'm trying to implement a feature and I need the index number of the currently selected item in the list view. So if it's 4th on the list I need a method that will return 3 because I need to edit the corresponding object in an ArrayList.

How can I do this?

Upvotes: 5

Views: 13081

Answers (1)

James_D
James_D

Reputation: 209418

Use

listView.getSelectionModel().getSelectedIndex();

Upvotes: 12

Related Questions