Benjamin VR Benjamin VR - 1 year ago 360
Java Question

Javafx WARNING: Resource "style.css" not found intellij

I am making a simple Javafx application with FXML.
My files are all in the same package:



  • style.css

  • MainApp.fxml

My root tag from the
file contains:

<GridPane fx:id="myRootPanel"
maxHeight="-Infinity" maxWidth="-Infinity"
minHeight="-Infinity" minWidth="-Infinity"
xmlns="" xmlns:fx=""

as you see there is a
, which was even autocompleted by Intellij.

When I open this
file in Scenebuilder, the css is applied correctly, but when I run the project, I get following console messages:

WARNING: Resource "style.css" not found.

I have added
to my Resource patterns, did a clean build, invalidated cache, but none of these resolve my problem.

I tried to make a simple application in NetBeans, and when I run that project there, the CSS is applied correctly. Because of this, I think there might be a problem/setting in the Intellij IDE to solve this... Does anyone know what to do?

Thanks in advance.


Answer Source

Seems like the @style.css does not work, instead I used the relative folder path, starting from the root (src): /css/style.css.