I have a JavaFX project (in NetBeans) with multiple fxml files. Is there any way to assign individual css files for each of these fxml files? I want to make different .root{...} settings for each fxml. Is it possible?
1 Answer
Add to each FXML file the associated css file:
<stylesheets>
<URL value="@stylesheet.css" />
</stylesheets>
Make sure that stylesheet.css is somewhere on the CLASSPATH.
Edit: if you want one global css for many fxml files, add the fx:id to the root pane in your fxml files , and use the ID in your css, root in the default value.
#fxml_1 {
... style from the fxml file with fx:id = "fxml_1", and so on
}
1 Comment
kornisb
It's okay, but then the .root{...} record in the css file is ignored. So I want different .root{...} settings in every different css file. Is it possible?