如何更改JavaFX中的突出显示颜色?

时间:2013-01-02 17:32:43

标签: java css javafx-2 javafx

如何更改JavaFX中的突出显示颜色?通常它是渐变的蓝色,但我希望有一个绿色突出显示。我尝试过以下方法:

.root{
    -fx-shadow-highlight-color: #CCFF99;
}

感谢您的帮助!

3 个答案:

答案 0 :(得分:19)

查看 caspian.css (JavaFX 2)或 modena.css (JavaFX 8)

.root {
    /* A bright blue for highlighting/accenting objects.  For example: selected
     * text; selected items in menus, lists, trees, and tables; progress bars;
     * default buttons.
     */
    -fx-accent: #0093ff;

    /* A bright blue for the focus indicator of objects. Typically used as the
     * first color in -fx-background-color for the "focused" pseudo-class. Also
     * typically used with insets of -1.4 to provide a glowing effect.
     *
     * TODO: should this be derived from -fx-accent?
     */
    -fx-focus-color: #0093ff;
}

根据用途改变这些颜色。

答案 1 :(得分:1)

我认为Uluk Biy回答得很好。

但是现实是使用CSS样式不会覆盖-fx-focus-color:#0093ff,而是会重叠。如果使用-fx-focus-color:red,它将与默认的蓝色混合,并显示类似颜色的灰色阴影。 css属性-fx-accent没有问题。

答案 2 :(得分:0)

您还可以在-fx-highlight-fill类选择器上使用text-area

.text-area {
    -fx-highlight-fill: green;
}