简体   繁体   English

JavaFX8 -fx-background-image不起作用

[英]JavaFX8 -fx-background-image doesn't work

I want to set background image of root-pane. 我想设置根窗格的背景图像。 For this purpose, I add this inline style to root-pane. 为此,我将此内联样式添加到根窗格中。

-fx-background-image: url("image.png");

Image is in same directory as FXML file. 图像与FXML文件位于同一目录中。 I checked path at least 10 times. 我检查路径至少10次。 Can somebody say, what's wrong? 有人可以说,怎么了?

Don't use inline style for fxml. 不要对fxml使用内联样式。 There is a discussion here : 这里有一个讨论:

https://community.oracle.com/thread/2595120?start=0&tstart=0
Please pay attention James_D's answer. 请注意James_D的回答。

By the way, if you use external css file, your code will work. 顺便说一句,如果您使用外部css文件,您的代码将起作用。 Please try 'styleclass' property in root tag. 请尝试在根标记中使用'styleclass'属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM