Skip to content
Projets

À propos

ScalaFX simplifie la création d’interfaces utilisateur basées sur JavaFX en Scala.

Développement web et applicatif

Comment ces chiffres sont mesurés

Progression mesurée des étoiles

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
Historique en cours

Variations nettes sur des périodes qui se chevauchent, pas des totaux quotidiens. Les mesures absentes restent vides. Les étoiles indiquent l’intérêt, pas la qualité.

README.md

Original

ScalaFX

GitHub Discussions

Scala CI Maven Central Version Scaladoc License

ScalaFX is a UI DSL written within the Scala Language that sits on top of JavaFX. This means that every ScalaFX application is also a valid Scala application. By extension, it supports full interoperability with Java and can run anywhere the Java Virtual Machine (JVM) and JavaFX are supported.

Have a question or an idea? Join us in ScalaFX Discussions.

Example of an ScalaFX App:

ScalaFX Ensemble application showing a gallery of ScalaFX controls and charts

Quick Start

ScalaFX binaries are published in the Maven Central repository as org.scalafx:scalafx_3. With SBT, add:

libraryDependencies += "org.scalafx" %% "scalafx" % "27.0.0-R39"

ScalaFX 27 requires JDK 25 or newer (a JavaFX 27 requirement). See Compatibility and Versioning for older versions.

Hello ScalaFX

A minimal ScalaFX application in Scala 3. Save it as HelloApp.scala and run it with Scala CLI using scala-cli HelloApp.scala:

//> using dep org.scalafx::scalafx:27.0.0-R39

import scalafx.application.JFXApp3
import scalafx.scene.Scene
import scalafx.scene.control.Label
import scalafx.scene.layout.StackPane

object HelloApp extends JFXApp3:
  override def start(): Unit =
    stage = new JFXApp3.PrimaryStage:
      title = "Hello ScalaFX"
      scene = new Scene(300, 200):
        root = new StackPane:
          children = new Label("Hello, ScalaFX!")
HelloApp window showing the centered text 'Hello, ScalaFX!'

For more details, including how to create a full SBT project, see For the Impatient on the ScalaFX website.

Documentation

Demo Projects and Examples

The ScalaFX Organization on GitHub contains sample projects that illustrate the use of ScalaFX:

  • scalafx-hello-world - the simplest SBT project, recommended to start with
  • ScalaFX-Hello-World-Gradle - the same, built with Gradle
  • scalafx.g8 - Giter8 template for new ScalaFX projects, use it with sbt new scalafx/scalafx.g8
  • ScalaFX-Tutorials - examples of using ScalaFX, each in a small standalone project
  • scalafx-ensemble - a gallery of over 60 sample applications (controls, charts, graphics, media, and web views) with their source code
  • ProScalaFX - examples from the "Pro JavaFX" books translated to ScalaFX
  • scalafx-extras - additions to ScalaFX that do not have corresponding concepts in JavaFX, with demos

Build Tool Setup

SBT
libraryDependencies += "org.scalafx" %% "scalafx" % "27.0.0-R39"

SBT resolves the JavaFX modules, including the platform-specific ones, through the ScalaFX dependency. There is no need to add them explicitly.

You can find examples of SBT setup in section Demo Projects and Examples.

Mill

If you're using Mill:

//| mill-version: 1.1.10

package build
import mill._, scalalib._

object yourProject extends ScalaModule {
  def jvmId = "temurin:25" // JavaFX 27 requires JDK version >= 25
  def scalaVersion = "3.7.3"

  // Add dependency on JavaFX libraries
  val javaFxVersion = "27"
  val scalaFxVersion = "27.0.0-R39"
  val javaFxModules = List("base", "controls", "fxml", "graphics", "media", "swing", "web")

  def mvnDeps = Seq(
    mvn"org.scalafx::scalafx:$scalaFxVersion"
  ) ++ javaFxModules.map(mod => mvn"org.openjfx:javafx-$mod:$javaFxVersion")
}

Unlike SBT, Mill does not resolve the platform-specific JavaFX modules through the ScalaFX dependency, so the JavaFX modules are listed explicitly.

You can find a sample ScalaFX Mill project here: scalafx-millproject

Gradle

Example of build.gradle:

plugins {
    id 'scala'
    id 'application'
    id 'org.openjfx.javafxplugin' version '0.1.0'
}

repositories {
    mavenCentral()
}

javafx {
    version = "27"
    modules = ['javafx.controls', 'javafx.media']
}

dependencies {
    implementation 'org.scala-lang:scala3-library_3:3.3.8'
    implementation 'org.scalafx:scalafx_3:27.0.0-R39'
}

application {
    mainClass = 'hello.ScalaFXHelloWorld'
}

A complete sample Gradle project can be found in ScalaFX-Hello-World-Gradle.

Compatibility and Versioning

Compatibility of Recent Versions

ScalaFX JavaFX Minimum JDK Scala
27.0.0-R39 27 25 3.3+, 2.13, 2.12
26.0.0-R38 26 24 3.3+, 2.13, 2.12
25.0.2-R37 25 23 3.3+, 2.13, 2.12
24.0.2-R36 24 22 3.3+, 2.13, 2.12
23.0.1-R34 23 21 3.3+, 2.13, 2.12
22.0.0-R33 22 17 3.3+, 2.13, 2.12

Each row shows the last release for that JavaFX version. Details for every release are in the notes folder.

What is in the version number

The ScalaFX version number has two parts. The first part corresponds to the latest JavaFX version it was tested with. The second part is an incremental release number. For instance, version 27.0.0-R39 means that it was tested with JavaFX version 27 and that it is the 39th release of ScalaFX.

Development Snapshots

Snapshot releases are published to the Maven Central snapshots repository. To use a snapshot build, add the Central snapshots resolver to your SBT configuration:

resolvers += Resolver.sonatypeCentralSnapshots

For other build tools, add https://central.sonatype.com/repository/maven-snapshots/ as a Maven repository.

Getting Help and Community

ScalaFX Discussions is the main place for the ScalaFX community. Use it to ask questions, share ideas, show your projects, and get announcements. Questions asked there are seen by the maintainers and other users, and the answers stay searchable for everyone.

We ask everyone to follow the Typelevel Code of Conduct in all ScalaFX community spaces: GitHub Discussions, issues, pull requests, and meetups.

Contributing

Contributions are welcome! See CONTRIBUTING.md for how to build ScalaFX from source, the project structure, coding guidelines, and how to submit pull requests.

License, Authors, and Credits

This software is licensed under the BSD 3-Clause License (BSD-3-Clause). The License text for this software can be found in LICENSE.txt in the root folder of the project.

ScalaFX was originally created by Stephen Chin, Java Champion, Oracle JavaOne program chair; and Sven Reimers, a member of the Netbeans Dream Team.

The most up to date list of contributors to the project can be found on the Contributors page.

Open Source Support

JetBrains logo.

Tooling provided by JetBrains. Thanks to JetBrains for supporting this project with Open Source development licenses.

Explorer des projets similaires

Chargement…