-
Notifications
You must be signed in to change notification settings - Fork 272
Application Startup
Wiki ▸ Documentation ▸ 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")
}
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.
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