Understanding binding collections

JavaFX 10 supports three main collection types—List, Map, and Set.

You can make any Java collection observable using FXCollections helper methods:

List observableList = FXCollections.observableArrayList(collection);

This makes a collection trigger a listener on every addition, removal, or change in the elements order.

The FXCollections class mimics java.util.Collections a lot, providing observable counterparts for java.util.Collections methods.

Note you can go even deeper, observing not only a collection but the collection elements' changes as well, using the following method:

<E> ObservableList<E> observableList(List<E> list, Callback<E, Observable[]> extractor)

Here, you need to additionally provide the  ...

Get Mastering JavaFX 10 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.