edvin / tornadofx

Lightweight JavaFX Framework for Kotlin
Apache License 2.0
3.68k stars 269 forks source link

In Java9+ importStyleSheet(String) wont work #982

Open dant3 opened 5 years ago

dant3 commented 5 years ago

Hi,

Just a heads-up that there is an issue with importStyleSheet(String) in FX.kt - it wont load your app css files on java9 because it resolves it via FX class, not target app class - and this class is located in tornadofx module, not your app module.

A quick workaround I did for my project is:

fun Any.importStylesheet(path: String) {
    val css = javaClass.getResource(path)
    if (css == null) {
        throw IllegalArgumentException("Unable to find $path")
    } else {
        tornadofx.importStylesheet(css.toExternalForm()) // this one works
    }
}

And then using this function in my Stylesheet class.

JonasGilg commented 5 years ago

In the very first line of the readme of TornadoFX you can find the following sentence:

Important: TornadoFX is not yet compatible with Java 9/10

edvin commented 5 years ago

We need these reports though, as they are valid for TornadoFX 2.0.0-SNAPSHOT :) I'll look into this ASAP.

dant3 commented 5 years ago

Yes, this is exactly the reason why I posted this

JonasGilg commented 5 years ago

Oh cool, I didn't even see the Java10 branch. Maybe it is best to label the bug reports when they were produced on the JDK10+ version of TornadoFX.