在我的.css文件中有类似于桌球的代码:
.table-cell-warn
{
-fx-background-color: aliceblue;
}
.table-cell-error
{
-fx-background-color: yellow;
}我已经将这些css类添加到特定的TableCells中。o.getStyleClass.add("table-cell-warn")或o.getStyleClass.add("table-cell-error")
但是,当我现在选择一个有色的TableRow时,它不使用为选定的TableRows指定的颜色(默认为浅蓝色)。我试着添加这样的代码:
.table-cell-warn:selected
{
-fx-background-color: #0096C9;
-fx-accent: #0096C9;
-fx-focus-color: #039ED3;
}
.table-cell-error:selected
{
-fx-background-color: #0096C9;
-fx-accent: #0096C9;
-fx-focus-color: #039ED3;
}到.css文件,但是没有任何改变。我是否也必须修改我的java代码中的某些内容?或者我走错路了。
发布于 2016-11-10 13:50:37
TableView处于“行选择模式”,这就是为什么将:selected伪类添加到包含TableCell的TableRow中。下列css应能工作:
/* for row selection mode */
.table-row-cell:selected .table-cell-warn,
.table-row-cell:selected .table-cell-error,
/* for cell selection mode */
.table-cell-warn:selected,
.table-cell-error:selected
{
-fx-background-color: #0096C9;
-fx-accent: #0096C9;
-fx-focus-color: #039ED3;
}https://stackoverflow.com/questions/40528994
复制相似问题