java - 使用场景构建器 8.5.0 自定义 java8 单选按钮
问题描述
我正在尝试创建一个程序,颜色对我很重要,我的问题是如何自定义单选按钮(更改蓝色环并更改选定的灰色圆圈和白色环)在此处输入图像描述
解决方案
最简单的是在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
推荐阅读
- performance - 需要增强我的 2MA 交叉买卖松树脚本,以便在横盘状态下不发出任何信号
- javascript - create-react-app 项目在第一次运行时显示错误
- android - Android Kotlin onClickListener 似乎隐藏了 MotionLayout 的 OnSwipe
- asp.net - 如何将远程调试器附加到崩溃的 ASP.NET 网站?
- laravel - 如何对 laravel excel 包中的验证错误进行分页?
- c# - 中间件 NET Core 3.1 上的 log4net LogicalThreadContext
- reactjs - NextJS - 仅在路线不同时运行 getInitialProps
- pandas - 基于值长度的 Pandas 数据框列条件检查
- windows - 如何使用 curl 或任何其他方法在 SF.net 下载最新版本的文件?
- python-3.x - concurrent.futures.ThreadPoolExecutor 没有在 DB 中插入值