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

ListView doesn't unselect correct items when Shift + left mouse btn is used

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 8
    • 8
    • javafx
    • b101

      To reproduce:

      1. Select 3 items using SHIFT + Left Mouse Button; Three items will be selected.
      2. Then make SHIFT + Left Mouse cilck on the first item
      Expected: Only the first item is selected
      Result: First and third items are selected

      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.SelectionMode;
      import javafx.scene.layout.StackPane;
      import javafx.stage.Stage;

      public class ListViewSelection extends Application {

          public static final ObservableList names =
                  FXCollections.observableArrayList();
          public static void main(String[] args) {
              launch(args);
          }

          @Override
          public void start(Stage primaryStage) {
              primaryStage.setTitle("List View Sample");

              final ListView listView = new ListView(names);
              listView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
              listView.setPrefSize(200, 250);
              names.addAll(
                      "Adam", "Alex", "Alfred", "Albert",
                      "Brenda", "Connie", "Derek", "Donny",
                      "Lynne", "Myrtle", "Rose", "Rudolph",
                      "Tony", "Trudy", "Williams", "Zach"

              );

              StackPane root = new StackPane();
              root.getChildren().add(listView);
              primaryStage.setScene(new Scene(root, 200, 250));
              primaryStage.show();
          }
      }

            jgiles Jonathan Giles
            dzinkevi Dmitry Zinkevich (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: