【问题标题】:Customising java8 radio buttons using scene builder 8.5.0使用场景构建器 8.5.0 自定义 java8 单选按钮
【发布时间】:2021-04-26 09:34:05
【问题描述】:

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

【问题讨论】:

    标签: java javafx radio-button scenebuilder


    【解决方案1】:

    最简单的方法是在 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

    【讨论】:

      猜你喜欢
      • 2022-01-19
      • 2015-07-04
      • 2021-12-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多