JavaFX styling TableColumn cells

大兔子大兔子 提交于 2019-12-24 07:50:26

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!