javafx - 如何在未聚焦的TableView中设置选定的行文本颜色

cha*_*pok 4 css javafx-2

我的应用程序使用行选择模式(table.setCellSelectionEnabled(false))

在我的CSS中:

.table-row-cell:selected {
   -fx-background-color: steelblue; 
   -fx-text-fill: red !important;
}
Run Code Online (Sandbox Code Playgroud)

财产-fx-background-color工作正常,但-fx-text-fill没有.所选行的文本颜色为黑色(如果TableView未聚焦)或白色(如果TableView聚焦).

Jam*_*s_D 16

这对我有用,虽然可能有更简单的方法:

.table-row-cell:selected {
   -fx-background-color: steelblue; 
}
.table-row-cell:selected .text {
       -fx-fill: red ;

}
Run Code Online (Sandbox Code Playgroud)