Fabio Olivetto
Fabio Olivetto

Reputation: 616

running through a loop inside a ListView in JavaFX

I managed to get the selected last value of the ListView with getSelectedItem(), but i cannot find out how to run through every value inside so that with SelectionMode.MULTIPLE i can get all the selected values.

listView.setOnMouseClicked(new EventHandler<MouseEvent>(){
        public void handle(MouseEvent event) {
            label.setText(listView.getSelectionModel().getSelectedItem());
        }
    });

Upvotes: 0

Views: 2183

Answers (1)

ItachiUchiha
ItachiUchiha

Reputation: 36722

You can use :

listView.getSelectionModel().getSelectedItems();

It will return a ObservableList<T> with all the selected items.

Upvotes: 2

Related Questions