Created
August 21, 2017 04:19
-
-
Save Dollyn/2beedf7f817b77037f6944505fe9bc11 to your computer and use it in GitHub Desktop.
Kotlin JavaFx example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package dollyn.sak | |
import javafx.application.Application | |
import javafx.event.ActionEvent | |
import javafx.event.EventHandler | |
import javafx.stage.Stage | |
import javafx.scene.Scene | |
import javafx.scene.control.Button | |
import javafx.scene.layout.StackPane | |
class SAKApplication : Application() { | |
override fun start(primaryStage: Stage) { | |
val btn = Button() | |
btn.text = "Say 'Hello World'" | |
btn.onAction = EventHandler<ActionEvent> { println("Hello World!") } | |
val root = StackPane() | |
root.children.add(btn) | |
val scene = Scene(root, 300.0, 250.0) | |
if (primaryStage != null) { | |
primaryStage.title = "Hello World!" | |
primaryStage.scene = scene | |
primaryStage.show() | |
} | |
} | |
} | |
fun main(args: Array<String>) { | |
Application.launch(SAKApplication::class.java, *args) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment