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

TableView: incorrect layout of last column

XMLWordPrintable

      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(
                      Locale.getAvailableLocales());
              locales.remove(10, locales.size());
              TableView<Locale> table = new TableView<>(locales);
              table.getSelectionModel().setCellSelectionEnabled(true);
              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);

              table.setTableMenuButtonVisible(true);
              CheckBox toggle = new CheckBox("toggle menubutton");
              toggle.selectedProperty().bindBidirectional(table.tableMenuButtonVisibleProperty());
              BorderPane pane = new BorderPane(table);
              pane.setBottom(toggle);
              return pane;
          }

          @Override
          public void start(Stage primaryStage) throws Exception {
              primaryStage.setScene(new Scene(getContent(), 300, 300));
              //primaryStage.setTitle(FXUtils.version());
              primaryStage.show();
          }
          
          public static void main(String[] args) {
              launch(args);
          }
          
          @SuppressWarnings("unused")
          private static final Logger LOG = Logger
                  .getLogger(TableViewHeaderLayoutLastColumn.class.getName());

      }

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

              Created:
              Updated: