Skip to content

Instantly share code, notes, and snippets.

@Dollyn
Created August 21, 2017 04:19
Show Gist options
  • Save Dollyn/2beedf7f817b77037f6944505fe9bc11 to your computer and use it in GitHub Desktop.
Save Dollyn/2beedf7f817b77037f6944505fe9bc11 to your computer and use it in GitHub Desktop.
Kotlin JavaFx example
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