Last active
February 3, 2026 20:24
-
-
Save dacr/01ee49f516a4da766deb7223db1a2d93 to your computer and use it in GitHub Desktop.
scalafx hello world example again / published by https://github.com/dacr/code-examples-manager #8ac3a4ce-b859-405a-be6b-e19fd86e6bdc/a4ead571d90eb26a05ec329a4e3e3c0a3dd28a56
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 again | |
| // keywords : scala, user-interface, javafx, scalafx, helloworld | |
| // publish : gist | |
| // authors : David Crosson | |
| // license : Apache License Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0.txt) | |
| // id : 8ac3a4ce-b859-405a-be6b-e19fd86e6bdc | |
| // created-on : 2024-01-07T21:16:09+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" | |
| // --------------------- | |
| // coming from | |
| // https://github.com/scalafx/scalafx/blob/master/scalafx-demos/src/main/scala/scalafx/JFXApp3Demo.scala | |
| import scalafx.application.JFXApp3 | |
| import scalafx.application.JFXApp3.PrimaryStage | |
| import scalafx.geometry.Insets | |
| import scalafx.scene.Scene | |
| import scalafx.scene.layout.HBox | |
| import scalafx.scene.paint.Color._ | |
| import scalafx.scene.paint._ | |
| import scalafx.scene.text.Text | |
| object JFXApp3Demo extends JFXApp3 { | |
| override def start(): Unit = { | |
| stage = new PrimaryStage { | |
| title = "ScalaFX Hello World!" | |
| scene = new Scene { | |
| fill = Color.rgb(38, 38, 38) | |
| content = new HBox { | |
| padding = Insets(50, 80, 50, 80) | |
| children = Seq( | |
| new Text { | |
| text = "Hello World!" | |
| style = "-fx-font: normal bold 100pt sans-serif" | |
| fill = new LinearGradient(endX = 0, stops = Stops(Red, DarkRed)) | |
| } | |
| ) | |
| } | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment