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

[TableView] setFixedCellSize causes new columns to be blank


    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 8u20
    • Fix Version/s: 8u40
    • Component/s: javafx
    • Environment:

      linux, windows 7, JDK 8 update 20


      The code below shows a TableView with one column and a button to add a second column. If the button is clicked the second column is added but it doesn't display any content. If setFixedCellSize is commented out then the second column is displayed as expected.

      If the column is removed and then added again it works as expected.

      import javafx.application.Application;
      import javafx.beans.property.SimpleStringProperty;
      import javafx.collections.FXCollections;
      import javafx.collections.ObservableList;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.TableColumn;
      import javafx.scene.control.TableView;
      import javafx.scene.control.cell.PropertyValueFactory;
      import javafx.scene.layout.FlowPane;
      import javafx.stage.Stage;

      public class FixedCellHeightTableTest extends Application {
          public void start(Stage stage) throws Exception {
              FlowPane flowPane = new FlowPane();
              Scene scene = new Scene(flowPane, 500, 500);

              ObservableList<Person> data = FXCollections.observableArrayList(
                      new Person("Jacob", "Smith"),
                      new Person("Isabella", "Johnson"),
                      new Person("Ethan", "Williams"),
                      new Person("Emma", "Jones"),
                      new Person("Michael", "Brown")

              TableView<Person> table = new TableView<>();
              TableColumn<Person,String> firstNameCol = new TableColumn<>("First Name");
              TableColumn<Person,String> lastNameCol = new TableColumn<>("Last Name");
              firstNameCol.setCellValueFactory(new PropertyValueFactory<>("firstName"));
              lastNameCol.setCellValueFactory(new PropertyValueFactory<>("lastName"));
              Button button = new Button("Add or Remove Column");
              button.setOnAction(actionEvent -> {
                  if (table.getColumns().size() == 1) {
                  } else {
              flowPane.getChildren().addAll(table, button);

          public static class Person {
              private final SimpleStringProperty firstName;
              private final SimpleStringProperty lastName;
              private Person(String fName, String lName) {
                  this.firstName = new SimpleStringProperty(fName);
                  this.lastName = new SimpleStringProperty(lName);
              public String getFirstName() {return firstName.get();}
              public void setFirstName(String fName) {firstName.set(fName);}
              public String getLastName() {return lastName.get();}
              public void setLastName(String fName) {lastName.set(fName);}

          public static void main(String[] args) {




            • Assignee:
              jgiles Jonathan Giles
              ndarcy Nick D'Arcy
            • Votes:
              0 Vote for this issue
              4 Start watching this issue


              • Created: