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

ListView with null SelectionModel/FocusModel throws NPE

    XMLWordPrintable

Details

    • b03
    • generic
    • generic

    Description

      When a null SelectionModel/FocusModel is set in a ListView, it will throw NPEs on various different actions,
      e.g. on clicking on a ListCell with a null SelectionModel or pressing space with a null FocusModel and more

      Example: Click on the first ListCell or press SPACE.
      ### SOURCE START ###
      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.control.ListView;
      import javafx.scene.layout.BorderPane;
      import javafx.stage.Stage;

      public class FXBug extends Application {

          public static void main(final String[] args) {
              launch(args);
          }

          @Override
          public void start(final Stage primaryStage) {
              ListView<String> listView = new ListView<>();
              listView.getItems().addAll("ABC", "DEF");

              listView.setFocusModel(null);
              listView.setSelectionModel(null);
              BorderPane root = new BorderPane(listView);

              final Scene scene = new Scene(root);
              primaryStage.setScene(scene);
              primaryStage.show();
          }
      }
      ### SOURCE END ###

      Attachments

        Issue Links

          Activity

            People

              mhanl Marius Hanl
              mhanl Marius Hanl
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: