4

is there a way to change the size of a checkbox in JavaFx 8? The default size is pretty big and I found no way to change it, not with css nor by using the API of the checkbox control itself.

NoMoreBugs
  • 141
  • 2
  • 7

3 Answers3

5

If you want to change the box's size of the CheckBox,you can use:

.check-box > .box {
    -fx-padding: 10px;
}

and you also want to change the check mark,you can use:

.check-box > .box > .mark {
    -fx-padding: 10px;
}

with the above css you can get a preview

enter image description here

All the javafx's built-in css selectors are in com/sun/javafx/scene/control/skin/caspian/caspian.css of jfxrt.jar

黄东辉
  • 111
  • 1
  • 3
0

Hey you could use the padding to achieve that. Here is an example with radiobuttons.

Javafx 2.0 : How to change the size of the radio-buttons circle with CSS?

Should be the same in JavaFX 8 since its done with css

Community
  • 1
  • 1
Juce
  • 341
  • 1
  • 8
0

The CheckBox class provides several methods to set the size. .setPrefSize() takes two doubles that set the preferred width and height.

        CheckBox box = new CheckBox();
        box.setPrefSize(prefWidth, prefHeight);
Dustin
  • 693
  • 8
  • 20