ScalaFX is a UI DSL written within the Scala Language that sits on top of JavaFX. Every ScalaFX application is also a valid Scala application. It supports full interoperability with Java and can run anywhere the Java Virtual Machine (JVM) and JavaFX are supported.
ScalaFX uses a simple, hierarchical pattern for creating new objects and building up the scene graph. Here is a simple, complete application example that creates a new stage (window) with a rectangle that changes color based on mouse events:
import scalafx.Includes._
import scalafx.application.JFXApp3
import scalafx.scene.Scene
import scalafx.scene.paint.Color._
import scalafx.scene.shape.Rectangle
object HelloStageDemo extends JFXApp3 {
override def start(): Unit = {
stage = new JFXApp3.PrimaryStage {
title.value = "Hello Stage"
width = 600
height = 450
scene = new Scene {
fill = LightGreen
content = new Rectangle {
x = 25
y = 40
width = 100
height = 100
fill <== when(hover) choose Green otherwise Red
}
}
}
}
}
Some of the features of ScalaFX include:
- A programmer-friendly object-literal-like syntax
- Natural Language Bind Expressions
- Tailored Animation Syntax
- Fully Type-Safe APIs
- Seamless JavaFX/ScalaFX Interoperability
To learn more watch the presentation below and read the Documentation section.
ScalaFX Overview Presentation
Stephen Chin presentation JavaFX 2 and Scala - Like Milk and Cookies (33 Degrees)
Support ScalaFX Project
Community Code of Conduct
We request all the team members to follow the Typelevel Code of Conduct in our mailinglist, issue discussion, Gitter room or any of ScalaFX meetups.