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

TableHeaderRow height not shrink after remove columns

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 8u40
    • javafx
    • x86
    • os_x

      FULL PRODUCT VERSION :
      java version "1.8.0_60"
      Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
      Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      OS X 10.10.5

      A DESCRIPTION OF THE PROBLEM :
      The computePrefHeight method of com.sun.javafx.scene.control.skin.TableHeaderRow consider height of cornerRegion to avoid RT-37616. That causes height of TableHeaderRow not shrink after remove nested columns from tables.
      For example, column col1 has one level nested columns, and column col2 is a leaf column. Height of col1 is 52. Height of col2 is 26. When col1 and col2 are added to tableview, height of TableHeaderRow should be 52 (maximun of col1 and col2). Later, remove col2 from tableview. The height of TableHeaderRow should be 26. But height cornerRegion of the TableHeaderRow is still 52.

      REGRESSION. Last worked in version 8u60


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------

              TableColumn<String, String> col1 = new TableColumn<>();
              col1.setText("col1");
              TableColumn<String, String> col2 = new TableColumn<>();
              col2.setText("col2");

              TableColumn<String, String> nestedCol1 = new TableColumn<>();
              nestedCol1.setText("nested col1");
              TableColumn<String, String> nestedCol2 = new TableColumn<>();
              nestedCol2.setText("nested col2");

              col1.getColumns().addAll(nestedCol1, nestedCol2);
              
              TableView<String> table = new TableView<>();
              table.getColumns().addAll(col1, col2);
              
              
              Button removeColumnButton = new Button("Button");
              removeColumnButton.setOnAction(event -> {
                  table.getColumns().remove(col1);
                  // after remove col1, height of header not adjust
              });
              
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      override method of computePrefHeight of com.sun.javafx.scene.control.skin.TableHeaderRow as below.

      @Override protected double computePrefHeight(double width) {
              return snappedTopInset() + getRootHeader().prefHeight(width) + snappedBottomInset();
      }

            jgiles Jonathan Giles
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: