I know there are plenty of solutions out there to help with changing the size of a radio button or check box, but I need a way to make the size relative using em in my .css file or some other inline solution.
I'm trying to get my controls to appear the same size in 720p, 1080p and 4K. All other controls besides RadioButton and CheckBox have worked by using em for whatever selector(s) controls size. I'll include some relevant code snippets below for each control.
RadioButton.css (the base font size is defined in another file)
.RadioButton {
-fx-font-size: 1em;
}
.RadioButton .radio {
-fx-background-insets: 0em;
-fx-background-radius: 0.833333em;
-fx-border-insets: 0em;
-fx-border-radius: 0.833333em;
-fx-padding: 0.5em;
}
.RadioButton:focused .radio {
-fx-background-insets: 0em;
-fx-background-radius: 0.833333em;
-fx-border-insets: 0em;
-fx-border-radius: 0.833333em;
-fx-padding: 0.5em;
}
.RadioButton:hover .radio {
-fx-background-insets: 0em;
-fx-background-radius: 0.833333em;
-fx-border-insets: 0em;
-fx-border-radius: 0.833333em;
-fx-padding: 0.5em;
}
.RadioButton:armed .radio {
-fx-background-insets: 0em;
-fx-background-radius: 0.833333em;
-fx-border-insets: 0em;
-fx-border-radius: 0.833333em;
-fx-padding: 0.5em;
}
.RadioButton .dot {
-fx-background-insets: 0em;
-fx-background-radius: 0.833333em;
-fx-padding: 0.4em;
}
.RadioButton:selected .dot {
-fx-background-insets: 0em;
}
Screenshots
When all of this is used the RadioButton gets larger and larger as the resolution goes from 4K -> 1080p -> 720p This makes me think that there is still some part of the control that is using its own internal hard size. I know usually you just change the padding value to achieve different sizes, but as you can see the padding values are already set in here with em.
Checkbox.css
.CheckBox {
-fx-font-size: 1em;
}
.CheckBox .box {
-fx-background-insets: 0em;
-fx-background-radius: 0.166667em;
-fx-border-insets: 0em;
-fx-border-radius: 0.166667em;
-fx-padding: 0.5em;
}
.CheckBox:focused .box {
-fx-background-insets: 0em;
-fx-background-radius: 0.166667em;
-fx-border-insets: 0em;
-fx-border-radius: 0.166667em;
}
.CheckBox:hover .box {
-fx-background-insets: 0em;
-fx-background-radius: 0.166667em;
-fx-border-insets: 0em;
-fx-border-radius: 0.166667em;
}
.CheckBox:armed .box {
-fx-background-insets: 0em;
-fx-background-radius: 0.166667em;
-fx-border-insets: 0em;
-fx-border-radius: 0.166667em;
}
.CheckBox .mark {
-fx-background-insets: 0.083333em 0em 0.083333em 0em, 0em;
-fx-padding: 0.5em;
-fx-shape: "M0,4H2L3,6L6,0H8L4,8H2Z";
}
Screenshots
This one is very similar to the RadioButton file where all values are using em instead of hard values. Could the -fx-shape that is part of the mark cause all of the em values to fail because it is a hard value?
Expectation
My end goal is to have radio buttons and check boxes stay exactly(extremely close) to the same size at different resolutions.