JavaFX is a GUI library for Java that can be used on desktop. The official documentation is available at https://openjfx.io. Also refer to their Getting Started with JavaFX guide.
You'll need a few things:
Download the JavaFX Modules from https://openjfx.io/. The jmods
download is the one with the modules and the SDK contains the .jar
files and dynamically linked libraries (e.g. .dylib
). The modules are for building runtimes with jlink and the library files are used for compiling. Optionally, also download the Scene Builder from https://gluonhq.com/products/scene-builder/ which is a visual GUI designer to generate .fxml
template files.
There are a few helpful resources to get started:
Here is a simple Hello World example:
// Feom https://github.com/openjfx/samples/blob/master/HelloFX/CLI/hellofx/HelloFX.java import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.control.Label; import javafx.scene.layout.StackPane; import javafx.stage.Stage; public class HelloFX extends Application { @Override public void start(Stage stage) { String javaVersion = System.getProperty("java.version"); String javafxVersion = System.getProperty("javafx.version"); Label l = new Label("Hello, JavaFX " + javafxVersion + ", running on Java " + javaVersion + "."); Scene scene = new Scene(new StackPane(l), 640, 480); stage.setScene(scene); stage.show(); } public static void main(String[] args) { launch(); } }