Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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! )

like image 415
Halfpint Avatar asked Feb 08 '14 18:02

Halfpint


1 Answers

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 java.net.*?> in the imports
  3. Add the below code at the end of parent pane, after </children> (in my case it was before </AnchorPane>):

    <stylesheets>
      <URL value="@MainView.css" />
    </stylesheets>
    
like image 119
Veelkoov Avatar answered Oct 26 '22 05:10

Veelkoov