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

TableView Header is not resized appropriately when TableView is empty

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P5 P5
    • tbd
    • 8u45
    • javafx
    • x86_64
    • windows_7

      FULL PRODUCT VERSION :
      java version "1.8.0_45"
      Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
      Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.1.7601]

      A DESCRIPTION OF THE PROBLEM :
      The header of a TableView/TreeTableView is not resized correctly when in constrained resize mode and the items of the TableView are cleared. The following will reproduce the problem. The column is not resized with the window after the table is empty.

      public class App2 extends Application {
        public static void main(String[] args) {
          launch(args);
        }

        @Override
        public void start(final Stage primaryStage) throws Exception {
          Pane root = new StackPane();

          TableView<String> tableView = new TableView<>();
          tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
          final TableColumn<String, String> column = new TableColumn<>();
          tableView.getColumns().add(column);

          column.setCellValueFactory(param -> new SimpleStringProperty("Hello"));
          final ObservableList<String> items = FXCollections.observableArrayList("1", "2", "3");
          tableView.setItems(items);

          Timeline timeline = new Timeline(new KeyFrame(Duration.seconds(5), event -> items.clear()));
          timeline.play();

          root.getChildren().add(tableView);

          Scene scene = new Scene(root);
          primaryStage.setScene(scene);
          primaryStage.show();
        }
      }


      The problem is within the layoutChildren() method in TableViewSkinBase which does not re-layout the inner VirtualFlow of the table when the TableView is empty. This later leads to problems in the updateContentWidth() method where the width of a column is based on the width of the VirtualFlow which still has its old value.


      REPRODUCIBILITY :
      This bug can be reproduced always.

        1. Test2.java
          2 kB
          Kevin Rushforth

            angorya Andy Goryachev
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: