Looked-up color fails for -fx-background-color in JavaFX CSS file

Duquette, Will (US 397J) william.h.duquette at jpl.nasa.gov
Tue Jun 8 20:32:14 UTC 2021


Howdy!

I'm migrating a code-base from JavaFX 8 to JavaFX 11, and I'm seeing some weird behavior.  I have some CSS that looks like this (in part)

.root {
     -theme-button: #0679DE;
}

.button-primary {
     -fx-background-color: -theme-button;
}

It's been working great in JavaFX 8 for quite a long while.  When I load the same app, I get messages like this written to the console.

Jun 08, 2021 10:40:07 AM javafx.scene.CssStyleHelper calculateValue
WARNING: Caught 'java.lang.ClassCastException: class java.lang.String cannot be cast to class javafx.scene.paint.Paint (java.lang.String is in module java.base of loader 'bootstrap'; javafx.scene.paint.Paint is in module javafx.graphics at 11.0.11 of loader 'platform')' while converting value for '-fx-background-color' from rule '*.button-primary' in stylesheet file:/Users/will/github/dgs-tool/out/production/dgs-lib/dsn-dark.css

Surprisingly, the color seems to still get set—but warnings written to the console are worrying.

If I replace -theme-button with #0679DE in the .button-primary style, the message goes away.

I'm seeing this for -fx-background-color and -fx-border-color, but not for any other places where I use looked-up colors.

Any ideas?




More information about the openjfx-dev mailing list