Setting Up

To use TornadoFX, there are several options to set up the dependency for your project. Mainstream build automation tools like Gradle and Maven are supported and should have no issues in getting set up.

Please note that TornadoFX is a Kotlin library, and therefore your project needs to be configured to use Kotlin. For Gradle and Maven configurations, please refer to the Kotlin Gradle Setup and Kotlin Maven Setup guides. Make sure your development environment or IDE is equipped to work with Kotlin and has the proper plugins and compilers.

This guide will use Intellij IDEA to walk through certain examples. IDEA is the IDE of choice to work with Kotlin, although Eclipse has a plugin as well.

Gradle

For Gradle, you can set up the dependency directly from Maven Central. Provide the desired version number for the x.y.z placeholder.

repositories {
    mavenCentral()
}
dependencies {
    compile 'no.tornado:tornadofx:x.y.z'
}

Maven

To import TornadoFX with Maven, add the following dependency to your POM file. Provide the desired version number for the x.y.z placeholder.

<dependency>
    <groupId>no.tornado</groupId>
    <artifactId>tornadofx</artifactId>
    <version>x.y.z</version>
</dependency>

Other Build Automation Solutions

For instructions on how to use TornadoFX with other build automation solutions, please refer to the TornadoFX page at the Central Repository

Manual Import

To manually download and import the JAR file, go to the TornadoFX release page or the Central Repository. Download the JAR file and configure it into your project.

Starting a TornadoFX Application

Newer versions of the JVM know how to start JavaFX applications without a main() method. A JavaFX application, and by extension a TornadoFX application, is any class that extends javafx.application.Application. Since tornadofx.App extends javafx.application.Application, TornadoFX apps are no different. Therefore you would start the app by referencing com.example.app.MyApp, and you don't necessarily need a main() function unless you need to supply command line arguments. In that case you would add a package level main function to the MyApp.kt file:

fun main(args: Array<String>) {
  Application.launch(MyApp::class.java, *args)
}

This main function would be compiled to com.example.app.MyAppKt - notice the Kt at the end. When you create a package level main function, it will always have a class name of the fully qualified package, plus the file name, appended with Kt.

results matching ""

    No results matching ""