Last active
March 13, 2016 13:14
-
-
Save CSaratakij/26581573c8f82309638e to your computer and use it in GitHub Desktop.
JavaFX with Kotlin1.0 : javafx ref -> http://docs.oracle.com/javase/8/javafx/get-started-tutorial/form.htm
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 playground.application | |
import javafx.application.Application | |
import javafx.scene.Scene | |
import javafx.stage.Stage | |
import javafx.scene.paint.Color | |
import javafx.scene.text.* | |
import javafx.scene.control.* | |
import javafx.scene.layout.* | |
import javafx.geometry.* | |
class App : Application() { | |
override fun start(primaryStage: Stage) { | |
primaryStage.setTitle("JavaFX with Kotlin language 1.0") | |
val grid = GridPane() | |
grid.setAlignment(Pos.CENTER) | |
grid.setHgap(10.0) | |
grid.setVgap(10.0) | |
grid.setPadding(Insets(25.0, 25.0, 25.0, 25.0)) | |
val sceneTitle = Text("Welcome") | |
sceneTitle.setFont(Font.font("Tahoma", FontWeight.NORMAL, 20.0)) | |
grid.add(sceneTitle, 0, 0, 2, 1) | |
val lblUserName = Label("User Name:") | |
grid.add(lblUserName, 0, 1) | |
val txtUserTextField = TextField() | |
grid.add(txtUserTextField, 1, 1) | |
val lblPassword = Label("Password:") | |
grid.add(lblPassword, 0, 2) | |
val pwfUserPasswordField = PasswordField() | |
grid.add(pwfUserPasswordField, 1, 2) | |
val lblActionTarget = Text() | |
grid.add(lblActionTarget, 1, 6) | |
val btnSignIn = Button("Sign in") | |
btnSignIn.setOnAction { | |
lblActionTarget.setFill(Color.FIREBRICK) | |
lblActionTarget.setText("Sign in button pressed.") | |
} | |
val hbBtn = HBox(10.0) | |
hbBtn.setAlignment(Pos.BOTTOM_RIGHT) | |
hbBtn.getChildren().add(btnSignIn) | |
grid.add(hbBtn, 1, 4) | |
val scene = Scene(grid, 640.0, 480.0) | |
primaryStage.setScene(scene) | |
primaryStage.show() | |
} | |
fun run(args: Array<String>) { | |
launch(*args) | |
} | |
} | |
fun main(args: Array<String>) { | |
App().run(args) | |
} |
thank you^_^
It's cleaner than a set method //I agree.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A bit cleaner version: