FULL PRODUCT VERSION :
A DESCRIPTION OF THE PROBLEM :
ListChangeListener.Change.getAddedSubList causes an IndexOutOfBoundsException if selecting items using Shift key. See steps to reproduce!
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1) Launch test case app
Item <1> is selected
2) Shift-Click on Item <2>
Items <1> and <2> are selected
3) Click on Item <3>
Item <3> is selected and IndexOutOfBoundException is thrown.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package sample;
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ListChangeListener;
import javafx.scene.Scene;
import javafx.scene.control.ListView;
import javafx.scene.control.SelectionMode;
import javafx.stage.Stage;
public class Main extends Application {
@Override
public void start(Stage primaryStage) {
final ListView<Integer> root = new ListView<>();
root.setItems(FXCollections.observableArrayList(1,2,3));
root.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
root.getSelectionModel().getSelectedItems().addListener((ListChangeListener<Integer>)(c -> {
while (c.next()) {
if (c.wasAdded()) {
System.out.println(c.getAddedSubList());
}
}
}));
root.getSelectionModel().select(0);
primaryStage.setScene(new Scene(root, 400, 400));
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
---------- END SOURCE ----------
A DESCRIPTION OF THE PROBLEM :
ListChangeListener.Change.getAddedSubList causes an IndexOutOfBoundsException if selecting items using Shift key. See steps to reproduce!
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1) Launch test case app
Item <1> is selected
2) Shift-Click on Item <2>
Items <1> and <2> are selected
3) Click on Item <3>
Item <3> is selected and IndexOutOfBoundException is thrown.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package sample;
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ListChangeListener;
import javafx.scene.Scene;
import javafx.scene.control.ListView;
import javafx.scene.control.SelectionMode;
import javafx.stage.Stage;
public class Main extends Application {
@Override
public void start(Stage primaryStage) {
final ListView<Integer> root = new ListView<>();
root.setItems(FXCollections.observableArrayList(1,2,3));
root.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
root.getSelectionModel().getSelectedItems().addListener((ListChangeListener<Integer>)(c -> {
while (c.next()) {
if (c.wasAdded()) {
System.out.println(c.getAddedSubList());
}
}
}));
root.getSelectionModel().select(0);
primaryStage.setScene(new Scene(root, 400, 400));
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
---------- END SOURCE ----------