Getting to Know ObservableLists
At their simplest, ObservableLists
are just Lists
that can register Listeners
fire whenever elements are added, removed or moved in the List
.
But, of course, there’s much more to it than that.
To begin with, it’s very hard to avoid ObservableLists
since they are critical to TableView
and ListView
. And, since they are used in ListView
they are also used in ComboBox
and ChoiceBox
. Pretty much anywhere a List
is used in JavaFX, it’s implemented as an ObservableList
. When you call HBox.getChildren()
, you’ll get an ObservableList
back.
So it’s very important to know how to deal with ObservableList
, and there’s also a catalogue of cool utilities and speciality classes that make it easy to do some fairly sophisticated things with ObservableLists
. To get the most out of JavaFX, it’s important to know about these, too.
The Articles:
The Beginners Guide to ObservableLists
This is the starting place for understanding the ObservableLists. In this article we cover all the basics that you need to master to be able to use ObservableLists effectively.
ObservableList Extractors
While ObservableLists will tell you when items have been added or removed, what if your List items are composed of Properties that can change? Can you get an ObservableList to fire a Listener when one of the component fields changes? Sure you can. This article will show you how.
The List Observables
In this article we look at ListProperty, the mysterious ObjectProperty