r/JavaFX • u/hamsterrage1 • Aug 11 '25
Tutorial New Article: List Extractors
https://www.pragmaticcoding.ca/javafx/elements/extractorsI'm looking to wrap up all my articles on the JavaFX Observable classes, and most of the last subjects left involve ObservableLists.
If you don't know ObservableList Extractors allow you to trigger listeners on an ObservableList when the List items are composed of ObservableValues.
For instance, let's say that you have a CustomerModel as your List items, and the CustomerModel has a bunch of StringProperties as its fields. Things like firstName, lastName, city, address - and they are all StringProperty.
Using an Extractor, you can trigger a Listener on the ObservableList when one of those CustomerModel has the value in one of those Property fields change. So if you changed, say, the firstName Property of one of the items, then the ObservableList would trigger a Listener.
Some of the native JavaFX Nodes, like TableView will detect changes to those fields without an Extractor, but Extractors can be really useful to trigger updates in Bindings that look inside the composed items.
Take a look and tell me what you think.
View all comments
Show parent comment
1
u/dazzlespace Aug 12 '25
I'm also a big fan of these articles - thank you for the effort you put into them!
To add observability to some of my classes in my hobby project https://github.com/dazzle50/JTableFX and because Java doesn't support multiple inheritance, I developed an interface
ISignalwith default method implementations. You can add this interface to any class to get some ready and working observability. You can probably tell I used Qt in the past 😂