├── project ├── build.properties └── plugin.sbt ├── .gitignore ├── LICENSE ├── src └── main │ └── scala │ └── hello │ └── ScalaFXHelloWorld.scala └── README.md /project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.10.11 2 | 3 | -------------------------------------------------------------------------------- /project/plugin.sbt: -------------------------------------------------------------------------------- 1 | scalacOptions ++= Seq("-unchecked", "-deprecation") 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | *.log 3 | .DS_Store 4 | 5 | # sbt specific 6 | .bsp/ 7 | .cache/ 8 | .history/ 9 | .lib/ 10 | dist/* 11 | target/ 12 | lib_managed/ 13 | src_managed/ 14 | project/boot/ 15 | project/plugins/project/ 16 | 17 | # Scala-IDE specific 18 | .scala_dependencies 19 | .worksheet 20 | 21 | /.idea/ 22 | /project/project 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /src/main/scala/hello/ScalaFXHelloWorld.scala: -------------------------------------------------------------------------------- 1 | package hello 2 | 3 | import scalafx.application.JFXApp3 4 | import scalafx.geometry.Insets 5 | import scalafx.scene.Scene 6 | import scalafx.scene.effect.DropShadow 7 | import scalafx.scene.layout.HBox 8 | import scalafx.scene.paint.* 9 | import scalafx.scene.paint.Color.* 10 | import scalafx.scene.text.Text 11 | 12 | import scala.language.implicitConversions 13 | 14 | object ScalaFXHelloWorld extends JFXApp3 : 15 | 16 | override def start(): Unit = 17 | 18 | stage = new JFXApp3.PrimaryStage : 19 | // initStyle(StageStyle.Unified) 20 | title = "ScalaFX Hello World" 21 | scene = new Scene : 22 | fill = Color.rgb(38, 38, 38) 23 | content = new HBox : 24 | padding = Insets(50, 80, 50, 80) 25 | children = Seq( 26 | new Text : 27 | text = "Scala" 28 | style = "-fx-font: normal bold 100pt sans-serif" 29 | fill = new LinearGradient(endX = 0, stops = Stops(Red, DarkRed)) 30 | , 31 | new Text : 32 | text = "FX" 33 | style = "-fx-font: italic bold 100pt sans-serif" 34 | fill = new LinearGradient(endX = 0, stops = Stops(White, DarkGray)) 35 | effect = new DropShadow : 36 | color = DarkGray 37 | radius = 15 38 | spread = 0.25 39 | ) 40 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | scalafx-hello-world 2 | =================== 3 | 4 | Simple example of a ScalaFX application using [Simple-Build-Tool](http://www.scala-sbt.org/) (SBT). 5 | 6 | Branches 7 | -------- 8 | 9 | Branch [master](https://github.com/scalafx/scalafx-hello-world/tree/master) contains an example with the current Scala 3 10 | syntax, 11 | branch [Scala2](https://github.com/scalafx/scalafx-hello-world/tree/Scala2) contains the same example with the old Scala 12 | 2 syntax. 13 | 14 | 15 | Content 16 | ------- 17 | 18 | * `src/main/scala/hello/ScalaFXHelloWorld.scala` - sample ScalaFX application. 19 | * `build.sbt` - the main SBT configuration file. 20 | * `project/build.properties` - version of SBT to use. 21 | * `project/plugins.sbt` - plugins used for creation of IDEA and Eclipse projects. 22 | 23 | How to build and Run 24 | -------------------- 25 | 26 | 1. Install [Java 17 JDK](http://www.oracle.com/technetwork/java/javase/downloads/index.html) or newer. 27 | If you are want to use Java 8 look at the [SFX-8](https://github.com/scalafx/scalafx-hello-world/tree/SFX-8) branch of this project. 28 | 29 | 2. Install [SBT](http://www.scala-sbt.org/) 30 | 31 | 3. Run the example: change to the directory containing this example and use SBT to build and run the example: 32 | 33 | ``` 34 | %> sbt run 35 | ``` 36 | 37 | It will download needed dependencies, including Scala and ScalaFX, and run the example code. 38 | 39 | Additional Information 40 | ---------------------- 41 | 42 | Detailed description of similar example can be found in the blog post 43 | ["Getting Started with ScalaFX: Compile and Run"](http://codingonthestaircase.wordpress.com/2013/05/17/getting-started-with-scalafx-compile-and-run-2/) 44 | . 45 | 46 | Gradle Version 47 | ----------- 48 | 49 | [Gradle](https://gradle.org/) version of this example can be found 50 | in [ScalaFX-Hello-World-Gradle](https://github.com/scalafx/ScalaFX-Hello-World-Gradle) 51 | --------------------------------------------------------------------------------