Last active
May 25, 2024 08:39
-
-
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/88e8bbfb122f025bdcd3b006a0250f28c6e9256d
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 NON-AI License Version 2.0 (https://raw.githubusercontent.com/non-ai-licenses/non-ai-licenses/main/NON-AI-APACHE2) | |
// 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