tly
tly

Reputation: 1272

JavaFX: Bind a list to a member property of elements of another list

I have a ObservableList<SomeDataClass> dataEntries and a ObservableList<StringProperty> dataNames.

I would like to create a binding that ensures that dataNames contains element.nameProperty() for each element in dataNames.

Is there something like the following code snippet in the FX libraries?

ObservableList<SomeDataClass> dataEntries = ...;
ObservableList<StringProperty> dataNames = ...;

dataNames.bind(dataEntries.memberList(SomeDataClass::nameProperty));

Upvotes: 2

Views: 404

Answers (1)

James_D
James_D

Reputation: 209418

Use the EasyBind framework. Then you can just do

ObservableList<SomeDataClass> dataEntries = ... ;
ObservableList<StringProperty> dataNames = 
    EasyBind.map(dataEntries, SomeDataClass::nameProperty);

Upvotes: 2

Related Questions