Build.gradle.kts
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { kotlin("jvm") version "1.4.10" id("org.openjfx.javafxplugin") version "0.0.9" } group = "cz.vitfo.redgui" version = "1.0-SNAPSHOT" repositories { mavenCentral() } tasks.withType() { kotlinOptions.jvmTarget = "11" } javafx { version = "15.0.1" modules = listOf("javafx.controls") }
Třída dědící z javafx.application.Application
import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.control.Label; import javafx.scene.layout.StackPane; import javafx.stage.Stage; class FXApplication : Application() { override fun start(stage: Stage) { val javaVersion = System.getProperty("java.version") val javafxVersion = System.getProperty("javafx.version") val l = Label("Hello, JavaFX $javafxVersion, running on Java $javaVersion.") val scene = Scene(StackPane(l), 640.0, 480.0) stage.scene = scene stage.show() } fun main(args: Array) { launch() } } fun main(args: Array) { FXApplication().main(args) }
Výsledná aplikace
Zdroj: github.com/openjfx/samples/blob/master/HelloFX/Gradle/hellofx/src/main/java/HelloFX.java