Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
226 views
in Technique[技术] by (71.8m points)

java - Customising java8 radio buttons using scene builder 8.5.0

I am trying to crate a program and colors are important to me , my question is how can i customise the radio button (Change the blue ring and change the selected Gray circle also the white ring)enter image description here

question from:https://stackoverflow.com/questions/65836321/customising-java8-radio-buttons-using-scene-builder-8-5-0

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The easiest is to do the styling in css. You can have a look at the modena.css (base css file for javafx). Copy the parts you need to your css file and edit the values as you need.

https://gist.github.com/maxd/63691840fc372f22f470 -> from line 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 */
}

Note that radiobutton extends other ui classes. The reference guide may help you understanding the hierarchy: https://docs.oracle.com/javase/8/javafx/api/javafx/scene/doc-files/cssref.html#radiobutton


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...