Situation
I'm trying to build a JavaFX App and for GUI I use SceneBuilder to produce fxml files for the different roots to use. Then I launch the App and at some point I'm trying to load some fxml file with new FXMLLoader(App.class.getResource("myFXML.fxml")).load()
and set it as root on the scene on the stage.
Issue
99% of the times the loading has no problem at all and everything works as intended, but that 1% will fail and prevent the fxml loading without stopping the App but only throws the warning bellow.
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@18 of loader 'app')' while converting value for
'-fx-background-color' from rule '*.list-view' in stylesheet
jar:file:///C:/mysystem/.m2/repository/org/openjfx/javafx-controls/18/javafx-controls-18-win.jar!/com/sun/javafx/scene/control/skin/modena/modena.bss
The fxml that causes it most of the time is the one with a ComboBox in it but i don't think this has to do with it since it happened anywhere.
Important the warning is not consistent as well, at the pre-last line instead of *.list-view
other times says *.button
as well, but i am doing the same action to test it.
Reproducing the Issue
Reproducing is not consistent at all, the warning is descriptive and seems that the problem is on a JavaFX file (mentioned in the warning) and not in something I wrote. Thus I can't find a consistent way to reproduce it or handle the exception or something.
Tried so far
- Removing the ComboBox (just in case)
- Searched the internet to find nothing about it
- Re-installing JDK did nothing
Note
I know there is much more information I can provide that may help but I'm exhausted right now. Maybe will add with edit later on.