0

I placed my css style sheet directly under the src directory, and then I try to add it to my javafx scene with the following piece of code:

scene.getStylesheets().add("style.css");

and then I get the following error:

com.sun.javafx.css.StyleManager loadStylesheetUnPrivileged
WARNING: Resource "style.css" not found.

I am using the eclipse IDE and initally I just had the css style sheet in the directory one level behind the src directory and I directly typed out the file path when trying to add the style sheet to my scene, but when using that method I received a null pointer exception. I'm not really sure what I am doing wrong, any help would be appreciated. Thanks.

  • Does this answer your question? [Can't load css file in javafx 8](https://stackoverflow.com/questions/50947109/cant-load-css-file-in-javafx-8) – fuggerjaki61 Jan 17 '20 at 18:08
  • 1
    please read the api doc (of scene.getStyleSheets()) to understand where the sheets are looked up (though it has a rather winded way of stating that it's an absolute path _[path] is treated as a path relative to the root of the application's classpath_ ;) – kleopatra Jan 18 '20 at 11:37
  • Yes, I just realized that the style.css folder has to be in the same directory as the .class files. Thanks :D – John Gunasar Jan 18 '20 at 20:25

0 Answers0