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

[TableColumn, TreeTableColumn] width property of nested table column is never updated.

XMLWordPrintable

      Run the code:

      import javafx.application.Application;
      import javafx.beans.property.SimpleStringProperty;
      import javafx.beans.value.ChangeListener;
      import javafx.beans.value.ObservableValue;
      import javafx.scene.Scene;
      import javafx.scene.control.TableColumn;
      import javafx.scene.control.TableView;
      import javafx.scene.layout.VBox;
      import javafx.stage.Stage;
      import javafx.util.Callback;

      public class JavaApplication4 extends Application {

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

          @Override
          public void start(Stage stage) throws Exception {
              VBox vb = new VBox();

              TableView<String> tv = new TableView<>();

              TableColumn tc1 = new TableColumn("Strings1");
              TableColumn tc2 = new TableColumn("Strings2");
              TableColumn nested = new TableColumn("Strings nested");
              tv.getColumns().add(nested);
              nested.getColumns().addAll(tc1, tc2);

              tv.getItems().addAll("One", "Two");

              tc1.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<String, String>, ObservableValue<String>>() {
                  @Override
                  public ObservableValue<String> call(TableColumn.CellDataFeatures<String, String> p) {
                      return new SimpleStringProperty(p.getValue());
                  }
              });

              tc2.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<String, String>, ObservableValue<String>>() {
                  @Override
                  public ObservableValue<String> call(TableColumn.CellDataFeatures<String, String> p) {
                      return new SimpleStringProperty(p.getValue());
                  }
              });

              tc1.widthProperty().addListener(new ChangeListener() {
                  @Override
                  public void changed(ObservableValue ov, Object t, Object t1) {
                      System.out.println("Called for column 1. New Value : " + t1);
                  }
              });

              tc2.widthProperty().addListener(new ChangeListener() {
                  @Override
                  public void changed(ObservableValue ov, Object t, Object t1) {
                      System.out.println("Called for column 2. New Value : " + t1);
                  }
              });

              nested.widthProperty().addListener(new ChangeListener() {
                  @Override
                  public void changed(ObservableValue ov, Object t, Object t1) {
                      System.out.println("Called for nested. New Value : " + t1); <- never seen this output.
                  }
              });

              vb.getChildren().add(tv);

              stage.setScene(new Scene(vb, 300, 300));
              stage.show();
          }
      }

      I resize nested column, column1 or column2. But updates on nested column width never comes.

      But I saw in internal test application, that sometimes it is updated.

      Also, it affects on tests, because it makes troubles for analysing of column headers structure.

            Unassigned Unassigned
            akirov Alexander Kirov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported: