微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用场景构建器 8.5.0 自定义 java8 单选按钮

如何解决使用场景构建器 8.5.0 自定义 java8 单选按钮

我正在尝试创建一个程序,颜色对我很重要,我的问题是如何自定义单选按钮(更改蓝色环并更改选定的灰色圆圈以及白色圆圈)enter image description here>

解决方法

最简单的就是在css中做样式。您可以查看 modena.css(javafx 的基本 css 文件)。将您需要的部分复制到您的 css 文件并根据需要编辑值。

https://gist.github.com/maxd/63691840fc372f22f470 -> 来自第 749 行

/*******************************************************************************
 *                                                                             *
 * RadioButton                                                                 *
 *                                                                             *
 ******************************************************************************/

.radio-button {
    -fx-label-padding: 0.0em 0.0em 0.0em 0.416667em; /* 0 0 0 5 */
    -fx-text-fill: -fx-text-background-color;
}
.radio-button > .radio,.radio-button:focused > .radio  {
   -fx-background-radius: 1.0em; /* large value to make sure this remains circular */
   -fx-padding: 0.333333em; /* 4 -- padding from outside edge to the inner black dot */
}
.radio-button > .radio > .dot {
   -fx-background-color: transparent;
   -fx-background-radius: 1.0em; /* large value to make sure this remains circular */
   -fx-padding: 0.333333em; /* 4 -- radius of the inner black dot when selected */
}

请注意,radiobutton 扩展了其他 ui 类。参考指南可以帮助您理解层次结构:https://docs.oracle.com/javase/8/javafx/api/javafx/scene/doc-files/cssref.html#radiobutton

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。