Correct way to set the path of a BackgroundImage in JavaFX CSS


I have an AnchorPane and I want to style it by giving it a BackgroundImage I have in another package : File Structure Screenshot

Here's the CSS I tried:


Using javascript I set the AnchorPane's CSS id to body; that didn't work. I tried to check other questions already asked, but they didn't help. Please can you clarify how, exactly, it should be done?

5/13/2017 3:59:50 AM

Accepted Answer

If your css file is loaded normally, Replacing:




should work.

The path is relative to the css file's directory, the .. accesses the parent directory (src); /Images refers to the Images directory; finally /FlowersPattern_beige_background.jpg accesses your image.

5/13/2017 6:15:06 AM

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