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

NPEs in ListView with no SelectionModel

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • jfx13
    • javafx
    • x86_64
    • linux_ubuntu

      A DESCRIPTION OF THE PROBLEM :
      While there are many places in ListViewBehavior that check if list's selection model is not null, there are still a couple of places that assume it exists. One of them is mousePressed method, triggered by clicking on cells, and another is activate, triggered by pressing either enter, space or f2 when list view has focus.

      You can reproduce it by creating a list view, setting it's selection model to null and then clicking on it's items and pressing enter.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Create an application with ListView without selection model:
      2. Run it
      3. Click on items in list view, or press Space, Enter or F2 with Listview in focus

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      no exceptions
      ACTUAL -
      null pointer exceptions

      ---------- BEGIN SOURCE ----------
      public static class TestApp extends Application {

          @Override
          public void start(Stage primaryStage) throws Exception {
              ListView<String> listView = new ListView<>(FXCollections.observableArrayList("a", "b", "c"));
              listView.setSelectionModel(null);
              primaryStage.setScene(new Scene(listView));
              primaryStage.show();

          }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      I can install custom event dispatcher on a list view that will prevent clicks and Space/Enter/F2 key presses from propagation

      FREQUENCY : always


            aghaisas Ajit Ghaisas
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: