1

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 1

2

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
}
Sign up to request clarification or add additional context in comments.

1 Comment

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?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.