JavaFX vs Swing

The standard UI toolkit in Java has (for the past years) been Swing. JavaFX is completely separate from Swing and is used completely on its own. Here we look at some of the biggest differences and advantages that JavaFX provides over swing.

Visuals

Unlike Swing, JavaFX does not bring multiple Look&Feel configurations that look more or less like a native application on each platform (though Swing's latest look&feel "Nimbus" has its very own skin). JavaFX has a default look that will be the same on all platforms. But a new feature that JavaFX brings, is CSS styling. You can change the look of all elements via CSS descriptions you might know from web development. This makes styling very easy and accessible to non-programmers who create the look of the UI. JavaFX also features animated UI elements which are not integrated in Swing.

Support

As JavaFX (version 8) is a fairly new technology only supported since Java 1.8 the target platform is smaller than that of Swing which

UI Definition

User interfaces in Swing are created programatically in Java. This is also possible in JavaFX but you also get FXML with JavaFX which allows you to define your user interfaces, their layouts and styling information in an XML file. This separation of UI definition and controls can help you clean up your code and allow non-programmers to design a user interface without touching the Java code.

More about this in the following section.