JavaFX

JavaFX is an open source, next generation client application platform for desktop, mobile and embedded systems built on Java.

The earliest versions of JavaFX were based on a scripting platform, but starting with JavaFX 2.0, it was migrated to an API as a core part of Java. Later, it was split out from Java core, and has been maintained as on open source project.

JavaFX is a great platform for building business applications to run on desktops. Unfortunately, it seems to be difficult to find good information about how to build applications in JavaFX on the web.

How To Approach JavaFX

I've been building desktop business applications in JavaFX since version 2 was released in 2014. It's taken most of that time to really understand the approach that should be taken to build application with JavaFX, the approach that the authors intended developers to take.

So why should it take so long to figure it out?

In my case, I was fairly new to Java when we started working with JavaFX, so my skills with Java in general were still growing as I was learning about JavaFX. Looking back, I can see that there were lots of clues about how to approach JavaFX, but I was overwhelmed with new concepts at the time, and missed most of them.

There's a lot to learn when you start out with JavaFX:

  • The Widgets and Layouts
  • Properties, Observables and Bindings
  • Events and Listeners
  • Model-View-Controller
  • The FX Application Thread
  • Animations
  • CSS and Styling

The Core Concept

The key element to understand with JavaFX is that every single component is designed to be integrated into your application via Bindings. The getValue() and setValue() (or whatever it may be called) of any input control should probably never be used in your programs. Instead, you should create a data Model for your screen, and bind a property in your data Model to the value property of the screen control in your View layout builder. Then your Controller can reference the properties in the data Model and they will always be synchronized with the values shown in the View.

Don't use Screen Builder or FXML

Just don't.

I'm Writing a Lot of JavaFX Blogs

Once you know how to approach JavaFX, building really nice looking, professional business applications is really easy - at least as far handling the look and feel is concerned. Designing a polished screen with a lot of functionality is surprisingly fast, and the actual JavaFX stuff should be just a very small portion of your overall code.

Over the years, I've gone back and refactored (or rewritten) screens that I had originally designed a few years earlier and I've always been surprised at how much extra code I could just throw away. I remember the code for one screen (including the business logic) shrunk to about 20% of what it started out as. These were improvements that came from a better understanding of how to approach writing JavaFX.

If you are interested in using JavaFX to build desktop applications, then you might find a lot of useful information in my blogs. My hope is to explain how to program with JavaFX so that you won't have to go through years of searching for the answer yourself.