JavaFX CSS error (attribute style sheet does not exist)

I've just started building JavaFX applications in IntelliJ using the latest Java 7 SDK

I have built my interface using Oracle scene builder, everything runs in the preview and displays normally, but when I try to compile my program, I receive the following error

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

Judge that the row style sheet = "@ mainview. CSS" in my fxml in JavaFX document will not display invalid

Does anyone know why I got this mistake? (if I delete the link to the style sheet, my program compiles well, so the problem is entirely the style sheet. I'm broken!)

Solution

You are creating an fxml in scene builder 2 and running it in JDK 7 Sb 2 "tries" to create Java 8 compatible fxml code Fix fxml:

>Delete stylesheets = "@ mainview. CSS" attribute > Add Add the following code at the end of the parent pane in import > and then < / children > (before < / anchorpane > in my case):

<stylesheets>
  <URL value="@MainView.css" />
</stylesheets>
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>