Skip to content
This repository has been archived by the owner on Sep 28, 2024. It is now read-only.

Application Startup

Edvin Syse edited this page Feb 18, 2016 · 9 revisions

WikiDocumentationApplication Startup

Application Startup

To define the entrypoint for your application, you extend the tornadofx.App class, which in turn extends javafx.application.Application. The only property you need to override is the reference to your primary view:

class HelloWorldApp : App() {
    override val primaryView = MyMainView::class
}

IntelliJ IDEA Users: Make sure you create an Application run configuration, not a Kotlin run configuration.

It is also customary to load stylesheets in the init block of the App class:

init {
    importStylesheet("/style.css")
}

Startup Parameters

Override start() or any other function that comes after it in the life cycle to access command line arguments. If you start your app with --myoption=myvalue you can access it via the parameters getter:

override fun start(stage: Stage) {
    val myoption = parameters.named["myoption"]
}

You can further override any JavaFX Lifecycle method if it fits your needs.

Application Instance

The actual application instance is available in the global variable FX.application. This can come in handy if you need to reference the application, like for example when getting an instance of the HostServicesFactory.

Next: Dependency Injection

Clone this wiki locally