JavaFX CSS Error ( Property Stylesheets does not exist )


I have just began building a JavaFX application in IntelliJ using the latest Java7 SDK.

I have built my interface using Oracle Scene Builder, everything runs and displays fine on the preview, but when I try and compile my program I get the following error

`Property "stylesheets" does not exist or is read-only`

Judging against JavaFX Documentation the line stylesheets="@MainView.css" in my FXML does not appear invalid.

Does anybody know why I am getting this error? ( If I remove the link to the stylesheet my program compiles just fine, so the problem lies solely with the stylesheet, I'm stumped! )

2/8/2014 6:14:51 PM

Accepted Answer

It turns out I needed to manually link the stylesheet in my start() method as JavaFX7 does not support the stylesheets tag.

To fix this I called the following command in my Start() method


Where root is the name of my FXMLLoader.

2/10/2014 2:24:27 PM

You were creating an FXML in Scene Builder 2 and running in JDK 7. SB 2 "tries to" create Java 8 compatible FXML code. To fix the FXML:

  1. Remove the stylesheets="@MainView.css" attribute
  2. Add <?import*?> in the imports
  3. Add the below code at the end of parent pane, after </children> (in my case it was before </AnchorPane>):

      <URL value="@MainView.css" />

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow