Encodera

Thanks for reading!

Donate to the site — we work hard for you.

Contents

What JavaFX is

JavaFX is a library for desktop applications in Java: windows with buttons, input fields, lists and tables. It draws the interface itself, so the same program looks the same on Windows, macOS and Linux. The look is tuned with ordinary CSS, and the window layout can be moved into a separate XML file called FXML.

Where JavaFX is used

  • internal business software: accounting, warehouses, operator workstations;
  • tools for engineers and developers: editors, data viewers, monitoring dashboards;
  • kiosks and touch-screen terminals;
  • student projects and simple games.

For example, Scene Builder, the visual window editor covered in its own lesson, is itself written in JavaFX.

The version in this course

JavaFX is developed as the open-source OpenJFX project. Since Java 11 it is not part of the JDK and is added as an ordinary Maven dependency, org.openjfx:javafx-controls. New versions come out every six months, following the JDK.

WhatVersion
Java (JDK)25
JavaFX25.0.4
Maven3.9
Build pluginjavafx-maven-plugin 0.0.8

JavaFX 25 runs on JDK 23 and newer. There are newer JavaFX releases too, but everything in this course works the same way in them.

What a window is made of

TermClassWhat it is
WindowStageThe window frame with a title and the minimize and close buttons
SceneSceneEverything inside the window
NodeNodeAny element: a button, a label, a container
LayoutVBox, BorderPane and othersA node that arranges other nodes
ControlButton, TextField and othersA node the user works with

Nodes are nested inside each other and form a tree called the scene graph. The root of the tree sits in the scene, and the scene sits in the window.

What we will build

One application runs through the whole course: a notebook. It will have a table of notes, a form for a new note with a title, text, a category and an "Important" check box, an edit window, confirmation dialogs and saving to a JSON file. We will package it as a program that runs on a computer without Java installed, and in the last chapter add animation, a statistics window with charts and a canvas for drawing.

What you need

You need JDK 25 and Maven. Check them in the terminal:

java -version
mvn -v

Both commands should print a version number. IntelliJ IDEA is a comfortable editor: it opens Maven projects without extra setup.

Common mistake

People look for JavaFX inside the JDK and write import javafx.application.Application; in a project without the dependency. The compiler answers error: package javafx.application does not exist. Since Java 11 the library has to be added in pom.xml; the next lesson shows how.

Thanks for reading!

Donate to the site — we work hard for you.