Benjamin VR Benjamin VR - 6 months ago 122
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:


  • MainApp.java

  • MainAppController.java

  • style.css

  • MainApp.fxml



My root tag from the
.fxml
file contains:

<GridPane fx:id="myRootPanel"
alignment="CENTER"
maxHeight="-Infinity" maxWidth="-Infinity"
minHeight="-Infinity" minWidth="-Infinity"
stylesheets="@style.css"
xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1"
fx:controller="sample.MainAppController">


as you see there is a
stylesheets="@style.css"
, which was even autocompleted by Intellij.

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

null/style.css
and
WARNING: Resource "style.css" not found.


I have added
*.css
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.

B.

Answer

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

Comments