ScalaFX is a UI DSL written within the Scala Language that sits on top of JavaFX 2 and JavaFX 8. 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 JavaFX2 or JavaFX8 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.JFXApp
import scalafx.scene.Scene
import scalafx.scene.paint.Color._
import scalafx.scene.shape.Rectangle

object HelloStageDemo extends JFXApp {
  stage = new JFXApp.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


How Donations Work