this post was submitted on 25 Feb 2024
6 points (100.0% liked)

JavaFX

118 readers
1 users here now

JavaFX is a software platform and a graphical user interface (GUI) toolkit that allows developers to create rich and interactive applications for desktop, mobile, and embedded devices. It provides a powerful set of tools and APIs for building modern, visually appealing applications.

JavaFX was introduced as a successor to the Swing framework. It is designed to provide a more advanced and flexible way of developing user interfaces compared to Swing, with improved graphics and multimedia capabilities.

Rules

  1. No NSFW/NSFL content
  2. No service requests/offers
  3. Must be JavaFX related
  4. No politics

founded 1 year ago
MODERATORS
 

You might have missed it, but there were some significant new features added to JavaFX in the 19 and 21 releases. These all relate to Observables, and make creating Bindings and Listeners easier to use.

I don't think enough noise was made about these when they came out, and I totally missed them until a little while ago. I spent some time experimenting with them, looking at the source code, and then wrote an article to explain just about everything you need to know:

https://www.pragmaticcoding.ca/javafx/subscribe_and_map

First, we now have some methods to create Subscriptions on Observables, and these are way easier to use than ChangeListener and InvalidationListener. Basically, Subscriptions are wrappers around the Listeners, so the same notification mechanism is used "under the hood", but they are easier to declare and manage.

Secondly, a new method has been added, ObseravbleValue.map(). This is super cool, and allows all kinds of conversions and calculations to be baked into any Binding with only one Observable dependency.

Finally, we now have ObservableValue.flatMap() which allows you to create bindings that reach through composed objects with Property fields. This is going to be massively useful in those cases where you need to bind the Property of a Property and have it re-evaluate if either the wrapper Property or the contained Property change.

Even if you don't normally read my articles, you should have a look at this. You'll probably want to upgrade all of your projects to JFX 21 right away - I know I do.

no comments (yet)
sorted by: hot top controversial new old
there doesn't seem to be anything here