The sub implementations of Tree- and TableCell shipped by JavaFX do not respect the row editability (inside startEdit()).
This issue persists also in the standard Tree- and TableCell. (seeJDK-8252238)
Affected classes:
- ComboBoxTableCell
- ComboBoxTreeTableCell
- ChoiceBoxTableCell
- ChoiceBoxTreeTableCell
- TextFieldTableCell
- TextFieldTreeTableCell
There are also 2 special cases: CheckBoxTableCell and CheckBoxTreeTableCell.
In this cells the corresponding CheckBox should consider the row editability when the disablement is calculated.
It is also recommended to do a null check before using the row editability.
There is a follow-up for this here: JDK-8270042
--- EXAMPLE ---
---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableRow;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.TextFieldTableCell;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
public class TableViewBug extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
TableView<Object> table = new TableView<>();
table.setEditable(true);
table.getItems().add(new Object());
TableColumn<Object, Boolean> column = new TableColumn<>("Select Me");
column.setCellFactory(p -> new TextFieldTableCell<>());
table.getColumns().add(column);
table.setRowFactory(p -> {
TableRow<Object> row = new TableRow<>();
row.setEditable(false);
return row;
});
Pane root = new Pane();
root.getChildren().add(table);
Scene scene = new Scene(root);
primaryStage.setScene(scene);
primaryStage.show();
}
}
---------- END SOURCE ----------
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
TextFieldTableCell should not be editable
ACTUAL -
TextFieldTableCell is editable
---
CUSTOMER SUBMITTED WORKAROUND :
As a temporary workaround, one can use the utility method suggested in https://stackoverflow.com/a/58905149
FREQUENCY : always
This issue persists also in the standard Tree- and TableCell. (see
Affected classes:
- ComboBoxTableCell
- ComboBoxTreeTableCell
- ChoiceBoxTableCell
- ChoiceBoxTreeTableCell
- TextFieldTableCell
- TextFieldTreeTableCell
There are also 2 special cases: CheckBoxTableCell and CheckBoxTreeTableCell.
In this cells the corresponding CheckBox should consider the row editability when the disablement is calculated.
It is also recommended to do a null check before using the row editability.
There is a follow-up for this here: JDK-8270042
--- EXAMPLE ---
---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableRow;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.TextFieldTableCell;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
public class TableViewBug extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
TableView<Object> table = new TableView<>();
table.setEditable(true);
table.getItems().add(new Object());
TableColumn<Object, Boolean> column = new TableColumn<>("Select Me");
column.setCellFactory(p -> new TextFieldTableCell<>());
table.getColumns().add(column);
table.setRowFactory(p -> {
TableRow<Object> row = new TableRow<>();
row.setEditable(false);
return row;
});
Pane root = new Pane();
root.getChildren().add(table);
Scene scene = new Scene(root);
primaryStage.setScene(scene);
primaryStage.show();
}
}
---------- END SOURCE ----------
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
TextFieldTableCell should not be editable
ACTUAL -
TextFieldTableCell is editable
---
CUSTOMER SUBMITTED WORKAROUND :
As a temporary workaround, one can use the utility method suggested in https://stackoverflow.com/a/58905149
FREQUENCY : always
- relates to
-
JDK-8252238 TableView: Editable (pseudo-editable) cells should respect the row editability
-
- Resolved
-