JavaFX TableView:无法覆盖'-fx-text-fill'! [英] JavaFX TableView: Cannot Override '-fx-text-fill'!
问题描述
在JavaFX2.2上,我创建了自己的样式类来表示包含无效数据的表单元格.但是我的样式类似乎无法覆盖hover
,selected
和focused
状态中的-fx-text-fill
.这是我的风格课:
On JavaFX2.2, I created my own style class to represent table cells that contain invalid data. But my style class seems unable to override -fx-text-fill
in the hover
, selected
, and focused
states. Here is my style class:
.invalid-table-cell {
-fx-text-fill: red;
}
.invalid-table-cell:hover {
-fx-background-color: salmon;
-fx-text-fill: blue; /* No worky */
}
.invalid-table-cell:selected {
-fx-background-color: purple;
-fx-text-fill: orchid; /* No worky */
}
.invalid-table-cell:focused:hover {
-fx-background-color: red;
-fx-text-fill: green; /* No worky */
}
运行我的应用程序时,我可以看到-fx-background-color
中的更改,但是在任何特殊状态下我都没有看到-fx-text-fill
中的更改.
When my app runs, I can see changes in -fx-background-color
, but I see no changes in -fx-text-fill
in any of the special states.
我在做什么错了?
推荐答案
按照jewelsea的建议,我提高了CSS规则的特异性,以匹配capsian.css
中相应规则的特异性.因为我很好奇,所以逐渐增加了自己的规则的特异性,发现在我的情况下,任何比以下规则更具体的规则都行不通.
Following jewelsea's advice, I increased the specificity of my CSS rules to match the specificity of the corresponding rules in capsian.css
. Because I was curious, I increased the specificity of my own rules incrementally and discovered that anything less specific than the following rules does not work in my situation.
.table-view:cell-selection .table-row-cell:filled .invalid-table-cell:hover {
/* Works! */
}
.table-view:focused .table-row-cell:filled .invalid-table-cell:selected:focused {
/* Works! */
}
.table-view:focused .table-row-cell:filled .invalid-table-cell:focused:selected:hover {
/* Works! */
}
这篇关于JavaFX TableView:无法覆盖'-fx-text-fill'!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!