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

TableView: incorrect layout of last column



    • Type: Bug
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: openjfx11
    • Fix Version/s: tbd
    • Component/s: javafx


      happens if menuButton is visible and vertical scrollbar is not visible

      To see, run the example below
       - make sure both scrollbars are visible and scroll to max
       - expected and actual: last header is fully visible and can be resized by mouse
       - extend height until vertical scrollbar is hidden
       - expected is same as with vertical scrollbar
       - actual: last header is cut off (text not fully visible) and can't be resized

      culprit seems to be mostly in layoutChildren of TableHeaderRow: it lets the rootHeader span the complete width (not caring about corner or not) and then relocates the corner where it belongs, which then is actually above the column header.

      There's probably more to fix: the last column header could be resized to less than its prefWidth (mitigating the cut-off of text a bit but then it's still too narrow). Or the virtualFlow could be aware of the possible corner and adjust the hbar accordingly - then the last cell must be wider than usual, to fill the gap to table's border. In both scenarios, columnHeader.width != cell.width.

      The example:

      public class TableViewHeaderLayoutLastColumn extends Application {

          private Parent getContent() {
              ObservableList<Locale> locales = FXCollections.observableArrayList(
              locales.remove(10, locales.size());
              TableView<Locale> table = new TableView<>(locales);
              TableColumn<Locale, String> countryCode = new TableColumn<>("CountryCode");
              countryCode.setCellValueFactory(new PropertyValueFactory<>("country"));
              TableColumn<Locale, String> language = new TableColumn<>("Language");
              language.setCellValueFactory(new PropertyValueFactory<>("language"));
              TableColumn<Locale, String> variant = new TableColumn<>("Variant");
              variant.setCellValueFactory(new PropertyValueFactory<>("variant"));
              TableColumn<Locale, String> display = new TableColumn<>("DisplayName");
              display.setCellValueFactory(new PropertyValueFactory<>("displayLanguage"));
              table.getColumns().addAll(display, countryCode, language, variant);

              CheckBox toggle = new CheckBox("toggle menubutton");
              BorderPane pane = new BorderPane(table);
              return pane;

          public void start(Stage primaryStage) throws Exception {
              primaryStage.setScene(new Scene(getContent(), 300, 300));
          public static void main(String[] args) {
          private static final Logger LOG = Logger





            aghaisas Ajit Ghaisas
            fastegal Jeanette Winzenburg
            0 Vote for this issue
            1 Start watching this issue