Image Not Found Using CSS In Java FX 2

Well, this took me awhile. But it was a pain not being able to load images from within my CSS file. The problem lies because the absolute path is different when you test it compared with the result when deployed.

Let us say this is how I want my button to look like:

CSS

1

2

3

4

#mybutton {

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

-fx-background-color:transparent;

}

When you run it in your local development environment, you wonder why the image would not load. Try to call this within your code