TornadoFX(JavaFX)-构建时,应用程序卡在“启动画面”上

时间:2018-08-26 17:49:09

标签: java javafx kotlin tornadofx jfoenix

我使用针对kotlin的tornadofx框架构建了一个应用程序。最近,我寻找一种方法来实现某种启动屏幕,该启动屏幕在实际应用程序之前弹出,以防首先加载大量文件。 我就是这样实现的:

应用启动:

class MyApp: App(LoginView::class) {
override fun start(stage: Stage) {
    super.start(stage)
    find<SplashScreenView>().openModal(stageStyle = StageStyle.UNDECORATED)
}

override fun shouldShowPrimaryStage() = false
}

fun main(args: Array<String>) {
    launch<MyApp>(args)
}

SplashScreen类:

class SplashScreenView: View() {

override val root by fxml<AnchorPane>("/fxml/SplashScreen.fxml")

val loadingText by fxid<Label>("loadingText")
val progressbar by fxid<JFXProgressBar>("progressbar")

init {
    currentStage?.apply {
        width = Screen.getPrimary().visualBounds.width / 2
        height = Screen.getPrimary().visualBounds.height / 1.5
    }

    loadingText.text = "Loading Account-Database ..."
}

override fun onDock() {
    super.onDock()
    currentStage?.centerOnScreen()

    close(); primaryStage.show()
}

}

奇怪的是,当我从fxml中删除进度栏(JFX或默认版本无关紧要)时,一切正常。但是当我将进度条构建为可运行的jar文件时,进度条会以某种方式阻止该应用程序的其余部分。当我从IDE启动它时,即使使用进度条,启动屏幕也会关闭并加载LoginView。 顺便说一句。控制台不会显示任何错误。

由于我没有将任何任务分配给进度条,有人知道这里会发生什么吗?

0 个答案:

没有答案