Last active
May 25, 2024 08:39
-
-
Save dacr/16538618317862094131b4fc3f3a5838 to your computer and use it in GitHub Desktop.
scalafx hello world example / published by https://github.com/dacr/code-examples-manager #f4009b1c-4c4b-40e1-a075-636175f03c46/159d161f46857efa9ec72167727db507a9405999
This file contains hidden or 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
// summary : scalafx hello world example | |
// keywords : scala, user-interface, javafx, scalafx, helloworld | |
// publish : gist | |
// authors : David Crosson | |
// license : Apache NON-AI License Version 2.0 (https://raw.githubusercontent.com/non-ai-licenses/non-ai-licenses/main/NON-AI-APACHE2) | |
// id : f4009b1c-4c4b-40e1-a075-636175f03c46 | |
// created-on : 2023-11-02T14:57:23+01:00 | |
// managed-by : https://github.com/dacr/code-examples-manager | |
// run-with : scala-cli $file | |
// --------------------- | |
// To setup the right jdk with javafx enabled : | |
// nix-shell nix-shell-scalafx.nix (https://gist.github.com/dacr/f64acff9d7e128183f721038e7e0a94d) | |
// --------------------- | |
//> using scala "3.4.2" | |
//> using dep "org.scalafx::scalafx:21.0.0-R32" | |
// --------------------- | |
// inspired from a X post from @rumbletumblekid : | |
// https://twitter.com/rumbletumblekid/status/1719376674939101576 | |
import scalafx.application.JFXApp3 | |
import scalafx.scene.Scene | |
import scalafx.scene.layout.VBox | |
import scalafx.scene.control.Label | |
import scalafx.geometry.Pos.Center | |
object Main extends JFXApp3 { | |
override def start(): Unit = { | |
stage = new JFXApp3.PrimaryStage { | |
width = 640 | |
height = 380 | |
scene = new Scene { | |
root = new VBox { | |
alignment = Center | |
children = Label("Hello World") | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment