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

TableColumnHeader: calc of cell width must respect row styling

XMLWordPrintable

      The example below has a odd row style with a bigger font size. Compile and run:

      - expected: column width such that text in all rows fully visible
      - actual: text in odd row is eclipsed

      Technically, the reason is the cell setup in resizeColumnToFitContent: it's only partially configured by adding to the table but not to a row, thus row styling is not applied.

      The example:

          public class TableColumnAutoSizing extends Application {
          
              private Parent createContent() {
                  TableView<String> table = new TableView<>(FXCollections.observableArrayList
                          ("short name", "and now really really longish name that exceeds all"));
                  TableColumn<String, String> name = new TableColumn<>("Name");
                  name.setCellValueFactory(cc -> new SimpleStringProperty(cc.getValue()));
                  table.getColumns().addAll(name);
                  BorderPane content = new BorderPane(table);
                  return content;
              }
          
              @Override
              public void start(Stage stage) throws Exception {
                  stage.setScene(new Scene(createContent(), 400, 200));
                  //stage.setTitle(FXUtils.version());
                  URL uri = getClass().getResource("tablecolumnautosizing.css");
                  stage.getScene().getStylesheets().add(uri.toExternalForm());
                  stage.show();
              }
          
              public static void main(String[] args) {
                  launch(args);
              }
          
          }

      tablecolumnautosizing.css:

      /* row styling not taken into accout on autosize
      */
      .table-row-cell:odd {
      -fx-font-size: 20;
      }

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

              Created:
              Updated:
              Resolved: