Java FX CSS @import path issue

Issue

In Java8_31 I imported different CSS files like that in my main.css:

@import "style/common/test1.css";
@import "style/common/test2.css";

All files were in the package style/common and it worked great.

Now with the build Java8_40 I did the same thing, but I get the following error message:

Could not find stylesheet:
file:/mypath/../style/common/style/common/test2.css
com.sun.javafx.css.parser.CSSParser handleImport

All my styles from the CSS file test1.css are working. What I was curious about was the fact that my path style/common is showing up two times.

So I tried to change my imports to the following:

@import "style/common/test1.css";
@import "test2.css";

With these imports, both styles of the file test1 and the file test2 are working. But both files are still in the same package.

Whats happening here? Is there a known issue about the @import and probably a problem in the CSSParser?

Solution

It actually is a known issue:

https://javafx-jira.kenai.com/browse/RT-40346

There is a temporary fix available and the issue should be fixed in the next build Java8_u60.

The temporary fix can be made in the CSSParser class. Link to the git diff:

http://hg.openjdk.java.net/openjfx/8u-dev/rt/rev/839912277bf0

If you dont want to try the fix or wait for u60, just add all css files to the same folder and import it like that (temporary solution!):

@import "css/test1.css";
@import "test2.css";
@import "test3.css";
@import "testX.css";

Answered By – NDY

Answer Checked By – Mildred Charles (AngularFixing Admin)

Leave a Reply

Your email address will not be published.