-
Bug
-
Resolution: Fixed
-
P3
-
8, 9, 10
-
java9-ea-u180
To reproduce, run example, start edit in any cell, cancel edit by ESC
- expected: print row value
- actual: NPE
The underlying reason is the incorrect tablePosition of the edit event: it must be equal to the one received in onEditStart but is null
The example
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.scene.Scene;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TablePosition;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.control.cell.TextFieldTableCell;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
/**
* TableView: NPE on access of event state on cancel
*/
public class TableViewEditCancelNPE extends Application {
TablePosition<TableColumn, String> editPosition;
@Override
public void start(Stage primaryStage) {
TableView<TableColumn> table = new TableView<>(
FXCollections.observableArrayList(new TableColumn("first"),
new TableColumn("second")));
table.setEditable(true);
TableColumn<TableColumn, String> first = new TableColumn<>("Text");
first.setCellFactory(TextFieldTableCell.forTableColumn());
first.setCellValueFactory(new PropertyValueFactory<>("text"));
first.setOnEditStart(t -> editPosition = t.getTablePosition());
first.setOnEditCancel(t -> {
if (!editPosition.equals(t.getTablePosition())) {
System.out.println("expected " + editPosition + " actual " + t.getTablePosition());
System.out.println("Desaster: NPE on access of event state");
t.getRowValue();
}
});
table.getColumns().addAll(first);
BorderPane root = new BorderPane(table);
Scene scene = new Scene(root, 300, 250);
primaryStage.setTitle("Hello World!");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
- expected: print row value
- actual: NPE
The underlying reason is the incorrect tablePosition of the edit event: it must be equal to the one received in onEditStart but is null
The example
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.scene.Scene;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TablePosition;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.control.cell.TextFieldTableCell;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
/**
* TableView: NPE on access of event state on cancel
*/
public class TableViewEditCancelNPE extends Application {
TablePosition<TableColumn, String> editPosition;
@Override
public void start(Stage primaryStage) {
TableView<TableColumn> table = new TableView<>(
FXCollections.observableArrayList(new TableColumn("first"),
new TableColumn("second")));
table.setEditable(true);
TableColumn<TableColumn, String> first = new TableColumn<>("Text");
first.setCellFactory(TextFieldTableCell.forTableColumn());
first.setCellValueFactory(new PropertyValueFactory<>("text"));
first.setOnEditStart(t -> editPosition = t.getTablePosition());
first.setOnEditCancel(t -> {
if (!editPosition.equals(t.getTablePosition())) {
System.out.println("expected " + editPosition + " actual " + t.getTablePosition());
System.out.println("Desaster: NPE on access of event state");
t.getRowValue();
}
});
table.getColumns().addAll(first);
BorderPane root = new BorderPane(table);
Scene scene = new Scene(root, 300, 250);
primaryStage.setTitle("Hello World!");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
- blocks
-
JDK-8266969 All Cells: cancelEvent must return correct editing location
-
- Closed
-
- is blocked by
-
JDK-8269136 Tree/TablePosition: must not throw NPE on instantiating with null table
-
- Resolved
-
- relates to
-
JDK-8165214 ListView.EditEvent.getIndex() does not return the correct index
-
- Resolved
-
-
JDK-8269871 CellEditEvent: must not throw NPE in accessors
-
- Resolved
-
-
JDK-8187226 ListView: EditEvent on cancel has incorrect index
-
- Closed
-
- links to
-
Commit openjdk/jfx/47c2ec3d
(1 links to)