I have observable list ObservableList<Integer> list = FXCollections.observableArrayList()
.
In getter method for list
I want to return read-only observable list, something like:
public ObservableList<Integer> getReadOnlyList() {
return readOnlyObservableList(list);
}
and then listen to read-only list
getReadOnlyList().addListener(listChangeListener);
So basically I want to return ObservableList list that is synchronized with original list, so that user can register ListChangeListener
and observe change events, but at the same time prevent user from changing the original list.
ObservableList<Integer> list = FXCollections.observableArrayList();
ObservableList<Integer> roList = FXCollections.unmodifiableObservableList(list);
public ObservableList<Integer> getReadOnlyList() {
return roList;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With