JavaFX 2 Tutorial

→ UPDATED VERSION for Java 8 available: JavaFX 8 Tutorial

JavaFX provides Java developers with a very nice graphics platform. In October 2011, JavaFX 2.0 was released. It was intended to be the choice for new graphical user interfaces (GUI) rather than the older Java Swing. When I started teaching JavaFX in 2012 it was still very early. There were no books covering JavaFX that I found suitable for students new to programming. So I started to write a very detailed tutorial series on JavaFX.

JavaFX Logo

The tutorial walks you through designing, programming and deploying an address application with JavaFX 2. This is how the final appllication will look like:

Screenshot AddressApp Part 1

What you will learn

  • Creating and starting a JavaFX project
  • Using Scene Builder to design the user interface
  • Structuring an application with the Model-View-Controller (MVC) pattern
  • Using ObservableLists for automatically updating the user interface
  • Using TableView and reacting to selection changes in the table
  • Create a custom popup dialog to edit persons
  • Validating user input
  • Styling a JavaFX application with CSS
  • Persisting data as XML
  • Saving the last opened file path in user preferences
  • Creating a JavaFX chart for statistics
  • Deploying a JavaFX application as a native package

This is quite a lot! So, after you you've completed this tutorial series you should be ready to build sophisticated applications with JavaFX.

How to use this Tutorial

There are two ways to use this tutorial:

  • learn-a-lot track: Create your own JavaFX project from the ground up.
  • fast track: Import the source code for a tutorial part into your IDE (it's an Eclipse project, but you could use other IDEs like NetBeans with slight modifications). Then go through the tutorial to understand the code. This approach is also helpful whenever you get stuck when you're on the learn-a-lot track!

Now, I hope you'll have fun and learn a lot! Start with Part 1: Scene Builder.