JavaFX select multiple items in ListView not working

I would like to have a ListView where the user can select multiple items. This is what I tried:

private ListView<String> createDependencyListView(){          List<String> values = createIssueModel.getIds();     ObservableList<String> items = FXCollections.observableArrayList(values);     ListView<String> list = new ListView<>(items);      list.setPrefWidth(50);     list.setPrefHeight(50);      list.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);     list.getSelectionModel().selectedItemProperty()         .addListener((ObservableValue<? extends String> ov, String old_val, String new_val) -> {          ObservableList<String> selectedItems = list.getSelectionModel().getSelectedItems();         });     return list; } 

But this is not working. I have two items in the list for testing and I can only select one at a time. Any idea what I am doing wrong here?

Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.