Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can you add splash-screen sample, please? #27

Open
ValeriusGC opened this issue Feb 27, 2018 · 2 comments
Open

Can you add splash-screen sample, please? #27

ValeriusGC opened this issue Feb 27, 2018 · 2 comments

Comments

@ValeriusGC
Copy link

Matter of fact i'd like to make splash screen without title so i do

    override fun start(stage: Stage) {
        stage.initStyle(StageStyle.UNDECORATED)

and get

image

But later i get undecorated main window

image

How can i do this thing right?

@edvin
Copy link
Owner

edvin commented Feb 27, 2018

There are many ways to skin the cat, but I prefer not to use the main stage for the splash screen. Something like this would work:

class SplashScreen : View("Please wait") {
    override val root = stackpane {
        setPrefSize(300.0, 100.0)
        label("Loading...")
    }

    override fun onDock() {
        thread {
            Thread.sleep(2000)
            runLater {
                close()
                primaryStage.show()
            }
        }
    }
}

class MainView : View("Main View") {
    override val root = stackpane {
        setPrefSize(800.0, 600.0)
        label("Welcome")
    }
}

class SplashApp : App(MainView::class) {
    override fun start(stage: Stage) {
        super.start(stage)
        find<SplashScreen>().openModal(stageStyle = StageStyle.UNDECORATED)
    }

    override fun shouldShowPrimaryStage() = false
}

@ValeriusGC
Copy link
Author

Thanx, it works good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants