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 button and a label that updates as the button is clicked:

import scalafx.application.JFXApp3
import scalafx.beans.property.IntegerProperty
import scalafx.geometry.Pos
import scalafx.scene.Scene
import scalafx.scene.control.{Button, Label}
import scalafx.scene.layout.VBox

object HelloStageDemo extends JFXApp3:

  override def start(): Unit =
    val clickCount = IntegerProperty(0)

    val messageLabel = new Label:
      text <== clickCount.asString("Clicked %d times")

    val button = new Button("Click Me"):
      onAction = _ => clickCount.value += 1

    stage = new JFXApp3.PrimaryStage:
      title = "Hello Stage"
      width = 300
      height = 150
      scene = new Scene:
        root = new VBox:
          alignment = Pos.Center
          spacing = 20
          children = Seq(messageLabel, button)

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

Donate

How Donations Work

Community Code of Conduct

We request all the team members to follow the Typelevel Code of Conduct in our mailing list, issue discussion, Gitter room or any of ScalaFX meetups.