Skip to content

Instantly share code, notes, and snippets.

@sifue
Last active May 26, 2016 05:37
Show Gist options
  • Select an option

  • Save sifue/24949b080df3beeb868a32644a723b23 to your computer and use it in GitHub Desktop.

Select an option

Save sifue/24949b080df3beeb868a32644a723b23 to your computer and use it in GitHub Desktop.
ScalaでJavaFXのHello Worldのテンプレート ref: http://qiita.com/sifue/items/ecd667459518e3ca6ae1
import javafx.application.Application
import javafx.event.{ActionEvent, EventHandler}
import javafx.scene.Scene
import javafx.scene.control.Button
import javafx.scene.layout.StackPane
import javafx.stage.Stage
object Main extends App {
Application.launch(classOf[Main], args: _*)
}
class Main extends Application {
override def start(primaryStage: Stage): Unit = {
val btn = new Button()
btn.setText("Say 'Hello World'")
btn.setOnAction(new EventHandler[ActionEvent] {
override def handle(event: ActionEvent): Unit = {
println("Hello")
}
})
val root = new StackPane()
root.getChildren.add(btn)
val scene = new Scene(root, 300, 250)
primaryStage.setTitle("Hello World!!")
primaryStage.setScene(scene)
primaryStage.show()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment