JavaFX CSS错误(属性样式不存在) [英] JavaFX CSS Error ( Property Stylesheets does not exist )
问题描述
我刚刚开始在IntelliJ中使用最新的Java7 SDK构建一个JavaFX应用程序。
I have just began building a JavaFX application in IntelliJ using the latest Java7 SDK.
我使用Oracle Scene Builder构建了我的界面,预览,但是当我尝试编译我的程序时,我得到以下错误
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`
判断JavaFX文档 stylesheets =@ MainView .css
在我的FXML中不显示无效。
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! )
推荐答案
事实证明,我需要手动链接样式表在我的start()方法,因为JavaFX7不支持样式表标签。
It turns out I needed to manually link the stylesheet in my start() method as JavaFX7 does not support the stylesheets tag.
在我的Start()方法中的以下命令
To fix this I called the following command in my Start() method
root.getStylesheets().add(this.getClass().getResource("view/MainView.css").toExternalForm());
其中 root
是我的FXMLLoader 。
Where root
is the name of my FXMLLoader.
这篇关于JavaFX CSS错误(属性样式不存在)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!