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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 8
    • Fix Version/s: 8
    • Component/s: javafx
    • Environment:

      b101

      Description

      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();
          }
      }

        Attachments

          Activity

            People

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

              Dates

              Due:
              Created:
              Updated:
              Resolved:
              Imported: