What I wanted to do is replace the standard JavaFX checkBox with my own pictures. I made many searches and I found :
- -fx-graphic : url
- -fx-background-image : url
But, in both cases, neither does what I want.
What I wanted to do is replace the standard JavaFX checkBox with my own pictures. I made many searches and I found :
But, in both cases, neither does what I want.
Here is the CSS I used to replace the checkbox with my own images. This is based off the JavaFX8 Modena stylesheet, but should be fairly close for Caspian. Replace the urls with the location of your images relative to your CSS sheet.
.check-box>.box {
-fx-background-insets: 0;
-fx-background-radius: 0;
-fx-background-color: transparent;
}
.check-box>.box>.mark {
-fx-background-image: url("unmarked.png");
-fx-background-position: center;
-fx-background-repeat: stretch;
-fx-shape: none;
}
.check-box:selected>.box>.mark{
-fx-background-color: transparent;
-fx-background-image: url("marked.png");
}
For a tutorial, please, consult the official documentation. There was a lot of new stuff that was added in 2.2. Also, the Introduction to FXML covers pretty much everything you need to know about FXML. Finally, Hendrik Ebbers made an extremely helpful blog post about custom UI controls.