Fixed cell size not working from css file

Viewed 45

I have a TableView and trying to fix the cell height through CSS. The following works from java:

myTable.setFixedCellSize(80);

But if I comment that out and rely on the following CSS it doesn't work.

#viewtable .table-row-cell {
    -fx-text-background-color: #7f7f7f;
    -fx-fixed-cell-size: 80px;
}

The id is set to viewtable, I've already confirmed I'm targeting the proper element as the text color takes affect. And using -fx-cell-size also works fine.

I'm launching this through eclipse and tried running from different environments from javase-1.8 up to 16. The javafx sdk is 17.0.0.1

1 Answers

The fixedCellSize property is part of the TableView class, not the TableRow class. This:

#viewtable .table-row-cell {
    -fx-text-background-color: #7f7f7f;
    -fx-fixed-cell-size: 80px;
}

Is applying the styles to any TableRow (at least by default) which is a descendent of the node with an ID of #viewtable.

Try the following:

#viewtable {
    -fx-fixed-cell-size: 80px;
}

#viewtable .table-row-cell {
    -fx-text-background-color: #7f7f7f;
}
Related