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

TableRowSkinBase: horizontal layout broken if row has padding



    • b02


      the row skin cell layout is completely broken if there's a padding on the row - below is an example for convenience, actually you can use whatever table you have handy ;)

      As you can see, the layout is broken in both location and sizing of the cells. Culprit is TableRowSkinBase.layoutChildren(x, y, ....) which is doing the wrong thingy at several places:

      protected void layoutChildren(double x, final double y, final double w, final double h) {
      // offset x and width are adjusted to insets, so taking them into account
      // again is most probably over-adjusting
              final double horizontalPadding = snappedLeftInset() + snappedRightInset();

      // adjusting the width for each column to the _row_ padding is
      // definitely the wrong thing

          double width;
          for(each-column) {
               width = cell.prefWidth(height) - horizontalPadding;
               cell.resize(width, ...)
               cell.relocate(x, ...)
               x += width;

      the very first cell has the correct position (because the param x is the correct offset), its width is too small by the rowPadding and the next cell is off in both location and width.

      Didn't dig further, but this basic layout quirk might be (part?) of the reason that TreeTableRow layout is completely broken ...

      The example:

      public class BugTableBugRowPadding extends Application {

          private Parent createContent() {
              TableView<Locale> table = createPlainTable();
              BorderPane content = new BorderPane(table);
              return content;

          private TableView<Locale> createPlainTable() {
              TableView<Locale> table = new TableView<>(
                      createColumn("displayCountry"), createColumn("displayLanguage"));
              return table;
          private TableColumn<Locale, String> createColumn(String property) {
              TableColumn<Locale, String> column = new TableColumn<>(property);
              column.setCellValueFactory(new PropertyValueFactory<>(property));
              return column;
          public void start(Stage stage) throws Exception {
              stage.setScene(new Scene(createContent()));
              URL uri = getClass().getResource("rowpadding.css");

          public static void main(String[] args) {

          private static final Logger LOG = Logger


      The css rowpadding.css:

          -fx-padding: 0 20 0 20 ;


          -fx-padding: 0 20 0 20 ;


        Issue Links



              mhanl Marius Hanl
              fastegal Jeanette Winzenburg
              0 Vote for this issue
              4 Start watching this issue