Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8094473

[ListView] Wrong change events fire in ListView

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 8u40
    • 8u25
    • javafx
    • Windows 8.1

    Description

      In a ListView with multi-selection, when selecting items with shift-up from the last one, we get the following change events:
      --- select the last item (for example by clicking on the last item) OK ---
      { [One] replaced by [Four] at 0, }
      -- select both last items (with Shift-up keys OK ---
      { [Three] added at 0, }
      -- select the three last items (with Shift-up keys KO ---
      { [Four] removed at 3, } and { [Two, Three] added at 0, }


      import javafx.application.Application;
      import javafx.collections.FXCollections;
      import javafx.collections.ListChangeListener;
      import javafx.collections.ObservableList;
      import javafx.scene.Scene;
      import javafx.scene.control.ListView;
      import javafx.scene.control.SelectionMode;
      import javafx.scene.layout.VBox;
      import javafx.stage.Stage;

      public class ListViewChangeEvent extends Application {
      @Override
      public void start(Stage primaryStage) throws Exception {
      ObservableList<String> items = FXCollections.observableArrayList("One", "Two", "Three", "Four");
      ListView<String> listView = new ListView<String>(items);
      listView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
      listView.getSelectionModel().getSelectedItems().addListener(new ListChangeListener<String>() {
      @Override
      public void onChanged(Change<? extends String> change) {
      System.out.println(change);
      }
      });
      VBox vBox = new VBox();
      vBox.getChildren().add(listView);
      Scene scene = new Scene(vBox);
      primaryStage.setScene(scene);
      primaryStage.show();
      }
      public static void main(String[] args) {
      Application.launch(args);
      }
      }

      Attachments

        Activity

          People

            jgiles Jonathan Giles
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported: