-
Bug
-
Resolution: Fixed
-
P4
-
8u5
-
Mac OS X 10.9.2: jdk1.8.0_05. Windows: Reproducible with 8.0.0-b132, but not 2.2.45-b18.
I have written a JavaFX sample that shows two ListViews side by side: The items of the right ListView are the selected items of the left ListView. The right ListView automatically tracks the selection changes of the first one.
This works fine, but there is an exception when trying to extend the selection beyond the lower end of the list using the keyboard: Selecting the last item of the list and then Shift+ArrowDown leads to this exception:
java.lang.IllegalStateException: Invalid Change state: next() must be called before inspecting the Change.
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Scene;
import javafx.scene.control.ListView;
import javafx.scene.control.MultipleSelectionModel;
import javafx.scene.control.SelectionMode;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;
public class rt36942 extends Application {
public static void main(String[] args) {
launch(args);
}
public void start(Stage stage) {
ObservableList<String> items = FXCollections.observableArrayList(
"Julia", "Ian", "Sue", "Matthew", "Hannah", "Stephan", "Denise");
ListView<String> listView = new ListView<>(items);
MultipleSelectionModel<String> selectionModel = listView.getSelectionModel();
selectionModel.setSelectionMode(SelectionMode.MULTIPLE);
ObservableList<String> selectedItems = selectionModel.getSelectedItems();
ListView<String> selectedItemsListView = new ListView<>(selectedItems);
HBox root = new HBox(5, listView, selectedItemsListView);
Scene scene = new Scene(root, 500, 300);
stage.setTitle("List View Sample");
stage.setScene(scene);
stage.show();
}
}
This works fine, but there is an exception when trying to extend the selection beyond the lower end of the list using the keyboard: Selecting the last item of the list and then Shift+ArrowDown leads to this exception:
java.lang.IllegalStateException: Invalid Change state: next() must be called before inspecting the Change.
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Scene;
import javafx.scene.control.ListView;
import javafx.scene.control.MultipleSelectionModel;
import javafx.scene.control.SelectionMode;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;
public class rt36942 extends Application {
public static void main(String[] args) {
launch(args);
}
public void start(Stage stage) {
ObservableList<String> items = FXCollections.observableArrayList(
"Julia", "Ian", "Sue", "Matthew", "Hannah", "Stephan", "Denise");
ListView<String> listView = new ListView<>(items);
MultipleSelectionModel<String> selectionModel = listView.getSelectionModel();
selectionModel.setSelectionMode(SelectionMode.MULTIPLE);
ObservableList<String> selectedItems = selectionModel.getSelectedItems();
ListView<String> selectedItemsListView = new ListView<>(selectedItems);
HBox root = new HBox(5, listView, selectedItemsListView);
Scene scene = new Scene(root, 500, 300);
stage.setTitle("List View Sample");
stage.setScene(scene);
stage.show();
}
}