CSS更改JFXRadioButton中的单选按钮颜色 [英] CSS Change radio button color in JFXRadioButton

查看:147
本文介绍了CSS更改JFXRadioButton中的单选按钮颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在此库中设置JFXRadioButton的样式时遇到问题: jfoenix.com

I have a problem with styling JFXRadioButton from this library : jfoenix.com

我想更改颜色或圆圈,但是默认类无效.你有什么想法吗?

I would like to change the color or circle, but default class didn't work. Have you to any ideas?

(仅用于测试的颜色.)

(Colors for tests only.. )

.radioButtonFX .radio:selected {
    -fx-background-color: yellow;
}

.radioButtonFX .radio-button .radio:selected {
    -fx-background-color: blue;
}

我还要更改JFXRippler的颜色和JFXTabPane中选定选项卡的行

I would like also change the color of JFXRippler and the line for selected tab in JFXTabPane

推荐答案

JFXRadioButton分配代码中的颜色.这优先于分配的值.修改CSS的唯一方法是使用JFXRadioButton本身的-fx-selected-color-fx-unselected-color属性:

JFXRadioButton assigns the color from code. This takes precedence over values assigned. The only way to modify this from CSS is using the -fx-selected-color and -fx-unselected-color properties of the JFXRadioButton itself:

.jfx-radio-button {
    -fx-selected-color: yellow;
    -fx-unselected-color: blue;
}

关于波纹颜色

.jfx-rippler {
    -fx-rippler-fill: lime;
}

以及所选标签下方的行

.jfx-tab-pane .tab-selected-line {
    -fx-stroke: red;
}

请注意,这里有一个 Node中的getCssMetaData方法,它使您可以检索可用属性的列表.

Note that there is a getCssMetaData method in Node, which allows you to retrieve a list of available properties.

radio.getCssMetaData().stream().map(CssMetaData::getProperty).forEach(System.out::println);

最后一个属性应该是JFX控件之一...

The last properties should be the one of the JFX control...

但这不适用于JTabPane,因为它们是Node子级的属性.对于该信息,似乎有必要深入研究JFXTabPane的默认外观的代码,因为JFoenix似乎在为该类编写属性文档方面做得很糟糕.

This does not work for JTabPane however, since those are properties of a child of the Node. For that info it seems to be necessary to dig through the code of the default skin for JFXTabPane, since JFoenix seems to have done a awful job at writing propert documententatiion for it's classes.

这篇关于CSS更改JFXRadioButton中的单选按钮颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆