问题
I am building a TableView in Gluon Scene Builder. I want to have a different background colour for cells in each column. Can I do this just through the FXML file and CSS?
With a CSS style class .column-1 I can do:
.column-1 {-fx-background-color: white;}
Except that also styles the column header! There doesn't seem to be a way to specify column cells only.
I have seen examples where people have managed it through java code - but doesn't this defeat the point of JavaFX having this CSS/FXML ability?
回答1:
You could use multiple class selectors to select the cells:
.column-1.table-cell {
-fx-background-color: white;
}
<TableColumn styleClass="column-1">
来源:https://stackoverflow.com/questions/47161501/javafx-styling-tablecolumn-cells