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

[TableView] NullPointerException when selecting with control and shift

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 9
    • 8u60
    • javafx
    • x86_64
    • windows_7

      FULL PRODUCT VERSION :
      java version "1.8.0_65"
      Java(TM) SE Runtime Environment (build 1.8.0_65-b17)
      Java HotSpot(TM) Client VM (build 25.65-b01, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.1.7601]

      A DESCRIPTION OF THE PROBLEM :
      I'm using a TableView with getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE) and getSelectionModel().setCellSelectionEnabled(false) and was able to produce a NullPointerException by modifying the focus and selection with keyboard.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. select the 2nd row with a mouse click
      2. press shift + up (modifies the selection)
      3. press control + right (modifies the cell focus, cell focus is not visualized)
      4. press shift + right (modifies the selection)


      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Exception in thread "JavaFX Application Thread" java.lang.NullPointerException
      at com.sun.javafx.scene.control.behavior.TableViewBehaviorBase.updateCellHorizontalSelection(TableViewBehaviorBase.java:812)
      at com.sun.javafx.scene.control.behavior.TableViewBehaviorBase.alsoSelectRightCell(TableViewBehaviorBase.java:690)
      at com.sun.javafx.scene.control.behavior.TableViewBehaviorBase.callAction(TableViewBehaviorBase.java:171)
      at com.sun.javafx.scene.control.behavior.BehaviorBase.callActionForEvent(BehaviorBase.java:218)
      at com.sun.javafx.scene.control.behavior.TableViewBehaviorBase.callActionForEvent(TableViewBehaviorBase.java:208)
      at com.sun.javafx.scene.control.behavior.BehaviorBase.lambda$new$74(BehaviorBase.java:135)
      at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
      at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
      at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
      at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
      at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
      at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
      at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
      at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
      at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
      at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
      at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
      at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
      at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
      at javafx.event.Event.fireEvent(Event.java:198)
      at javafx.scene.Scene$KeyHandler.process(Scene.java:3964)
      at javafx.scene.Scene$KeyHandler.access$1800(Scene.java:3910)
      at javafx.scene.Scene.impl_processKeyEvent(Scene.java:2040)
      at javafx.scene.Scene$ScenePeerListener.keyEvent(Scene.java:2501)
      at com.sun.javafx.tk.quantum.GlassViewEventHandler$KeyEventNotification.run(GlassViewEventHandler.java:197)
      at com.sun.javafx.tk.quantum.GlassViewEventHandler$KeyEventNotification.run(GlassViewEventHandler.java:147)
      at java.security.AccessController.doPrivileged(Native Method)
      at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleKeyEvent$354(GlassViewEventHandler.java:228)
      at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
      at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleKeyEvent(GlassViewEventHandler.java:227)
      at com.sun.glass.ui.View.handleKeyEvent(View.java:546)
      at com.sun.glass.ui.View.notifyKey(View.java:966)
      at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
      at com.sun.glass.ui.win.WinApplication.lambda$null$149(WinApplication.java:191)
      at java.lang.Thread.run(Thread.java:745)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javafx.application.Application;
      import javafx.beans.property.SimpleStringProperty;
      import javafx.beans.property.StringProperty;
      import javafx.collections.FXCollections;
      import javafx.collections.ObservableList;
      import javafx.scene.Scene;
      import javafx.scene.control.SelectionMode;
      import javafx.scene.control.TableColumn;
      import javafx.scene.control.TableView;
      import javafx.scene.control.cell.PropertyValueFactory;
      import javafx.scene.layout.VBox;
      import javafx.stage.Stage;

      public class TableViewExample extends Application {

          private void init(Stage primaryStage) {
              VBox root = new VBox(2);
              primaryStage.setScene(new Scene(root, 300, 300));

              final ObservableList<TableViewExample.Person> data = FXCollections.observableArrayList(
                      new Person("Jacob", "Smith", "jacob.smith@example.com"),
                      new TableViewExample.Person("Isabella", "Johnson", "isabella.johnson@example.com"),
                      new TableViewExample.Person("Ethan", "Williams", "ethan.williams@example.com"),
                      new TableViewExample.Person("Emma", "Jones", "emma.jones@example.com"),
                      new TableViewExample.Person("Michael", "Brown", "michael.brown@example.com"),
                      new TableViewExample.Person("Jacob", "Smith", "jacob.smith@example.com"),
                      new TableViewExample.Person("Isabella", "Johnson", "isabella.johnson@example.com"),
                      new TableViewExample.Person("Ethan", "Williams", "ethan.williams@example.com"),
                      new TableViewExample.Person("Emma", "Jones", "emma.jones@example.com"),
                      new TableViewExample.Person("Michael", "Brown", "michael.brown@example.com"),
                      new TableViewExample.Person("Jacob", "Smith", "jacob.smith@example.com" ),
                      new TableViewExample.Person("Isabella", "Johnson", "isabella.johnson@example.com" ),
                      new TableViewExample.Person("Ethan", "Williams", "ethan.williams@example.com" ),
                      new TableViewExample.Person("Emma", "Jones", "emma.jones@example.com" ),
                      new TableViewExample.Person("Michael", "Brown", "michael.brown@example.com" ));

              TableColumn firstNameCol = new TableColumn();
              firstNameCol.setText("First");
              firstNameCol.setCellValueFactory(new PropertyValueFactory("firstName"));
              TableColumn lastNameCol = new TableColumn();
              lastNameCol.setText("Last");
              lastNameCol.setCellValueFactory(new PropertyValueFactory("lastName"));
              TableColumn emailCol = new TableColumn();
              emailCol.setText("Email");
              emailCol.setCellValueFactory(new PropertyValueFactory("email"));
              TableView tableView = new TableView();
              tableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
              tableView.getSelectionModel().setCellSelectionEnabled(false);
              tableView.setItems(data);
              tableView.getColumns().clear();
              tableView.getColumns().addAll(firstNameCol, lastNameCol, emailCol);

              root.getChildren().addAll(tableView);
          }

          public static class Person {

              private StringProperty firstName;
              private StringProperty lastName;
              private StringProperty email;

              private Person(String fName, String lName, String email) {
                  this.firstName = new SimpleStringProperty(fName);
                  this.lastName = new SimpleStringProperty(lName);
                  this.email = new SimpleStringProperty(email);
              }

              public StringProperty firstNameProperty() {
                  return firstName;
              }

              public StringProperty lastNameProperty() {
                  return lastName;
              }

              public StringProperty emailProperty() {
                  return email;
              }
          }

          @Override
          public void start(Stage primaryStage) throws Exception {
              init(primaryStage);
              primaryStage.setTitle("Table Test " + System.getProperty("javafx.runtime.version"));
              primaryStage.show();
          }

          public static void main(String[] args) {
              launch(args);
          }
      }
      ---------- END SOURCE ----------

            jgiles Jonathan Giles
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: