I have created a JavaFX application that needs to run as an overlay. Because of different requirements we’re starting it with Platform.startup()
. The first stage that I create is a splash screen like so (pseudo-Kotlin follows):
class SplashScreen : Stage(StageStyle.TRANSPARENT) {
init {
isAlwaysOnTop = true
// create root, configure, etc.
val scene = Scene(root, w, h)
scene.fill = Color.TRANSPARENT
this.scene = scene
}
}
fun main() {
System.setProperty("apple.awt.UIElement", "true") // https://developer.apple.com/documentation/bundleresources/information_property_list/lsuielement
Platform.setImplicitExit(false) // Due to app requirements
Platform.startup {
instance = SplashScreen().apply { show() }
}
}
The problem with that code is that JavaFX seems to be ignoring the "apple.awt.UIElement"
property, and creates a menu and adds it to the application switch pane in macOS.
On the other hand, if I call Platform.startup()
inside a new thread it picks up the property without any issue and starts as required.
fun main() {
System.setProperty("apple.awt.UIElement", "true") // https://developer.apple.com/documentation/bundleresources/information_property_list/lsuielement
Thread {
Platform.setImplicitExit(false) // Due to app requirements
Platform.startup {
instance = SplashScreen().apply { show() }
}
}.start()
}
Why is this behaving that way? I would expect that the property should be picked up by JavaFX right after defining it.