Created
July 16, 2012 14:15
-
-
Save ngsw-taro/3122948 to your computer and use it in GitHub Desktop.
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
import javafx.application.Application | |
import javafx.event.ActionEvent | |
import javafx.geometry.Pos | |
import javafx.scene.Scene | |
import javafx.scene.control.Button | |
import javafx.scene.control.Label | |
import javafx.scene.layout.VBox | |
import javafx.stage.Stage | |
import kotlinfx.* | |
fun main(args: Array<String>) = Application.launch(JavaFxSample.javaClass) | |
object JavaFxSample : Application() { | |
override fun start(stage: Stage?) { | |
var count = 0 | |
val label = Label("$count") | |
val button = Button("Count") | |
button.setOnAction { | |
(event: ActionEvent) -> | |
label.text = "${++count}" | |
} | |
val vBox = VBox(20.0) | |
vBox.alignment = Pos.CENTER | |
vBox.children.add(label) | |
vBox.children.add(button) | |
val scene = Scene(vBox) | |
val style = JavaFxSample.javaClass.getResource("css/style.css")?.toExternalForm() | |
scene.stylesheets.add(style) | |
if (stage != null) { | |
stage.width = 400.0 | |
stage.height = 300.0 | |
stage.scene = scene | |
stage.title = "Counter" | |
stage.show() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment