【问题标题】:How can i Change the DOt in a JavaFx RadioButton?如何更改 JavaFx RadioButton 中的 DOt?
【发布时间】:2014-08-23 05:35:20
【问题描述】:

你好 Stackeroverflowers,

我想问一下如何更改 RadioButton Dot? 我需要定义 3 个具有 3 种不同颜色的 RadioButtons 来显示状态。 我必须使用 Css 吗? 如果有人能告诉我我怎么能意识到这一点,那就完美了?

一个例子是:

@FXML
public RadioButton redState = new RadioButton();
.
.
.
redState.setDotColor(red);

或在 Fxml 中定义颜色静态:

style="-fx-dot-color: rgb(255,0,0);" 

我希望每个人都理解我的计划。 它只是关于在 javafx RadioButton 中为 Dot 着色。

感谢每一个答案。

【问题讨论】:

    标签: css colors javafx radio-button fxml


    【解决方案1】:

    我没有测试过,但是试试

    redState.getStyleClass().add("red-radio-button");
    

    (如果您愿意,也可以在 FXML 中执行此操作)。

    然后在一个外部的css文件中

    .red-radio-button .dot {
      -fx-mark-highlight-color: red ;
      -fx-mark-color: red ;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-04-14
      • 2021-08-02
      • 2011-03-02
      • 2015-09-07
      • 2013-03-18
      • 2018-07-05
      • 2017-02-17
      相关资源
      最近更新 更多