3

I have lots of fxml files containing different types of javafx nodes such as VBox, etc. I want to know if it is possible to add a stylesheet to the scene which automatically applies on all VBox elements declared any where in my project (or even created programatically). I know that it is easily supported for buttons, since I can use .button {...} inside my custom .css file and add it to the scene. However, I can't find anything similar solution for lots of node types such as VBox, HBox, and so on.

I looked for such css tags like VBox inside modena.css which is placed somewhere inside standard jdk's jfxrt.jar. Unfortunately, I could not find such tags. I could not find any example on the oracle's website too.

Is there any way of doing so? Thanks for your helps.

Community
  • 1
  • 1
Amin
  • 292
  • 2
  • 11

1 Answers1

12

I myself found a solution. You can add this simple class name of a pane such as VBox to your .css file like this:

HBox, VBox {
    //css instructions here
    -fx-background-color: red;
}

Note that names are case sensitive; No dot is required before the name.

Amin
  • 292
  • 2
  • 11