Is there a CHANGEABLE ListProperty
in JavaFX?
I need a ListProperty
supprting add()
and remove()
methods, but I couldnt't find one.
SimpleListProperty
will throw UnsupportedOperationException
.
All I found is to use the initializer to set the contents, but that's not what I need. I need to start with an empty Property end buld from there.
I cannot believe there's no such a thing; I must be blind, somehow. Can someone point me in the right direction, please?
It turns out ListProperty()
is an empty wrapper.
It does not initialize the wrapped ObservableList<>
.
This is absolutely unclean from documentation and the UnsupportedOperationException
thrown is misleading (should be a NPE).
Default constructor is useless in normal usage, use something like:
ListProperty<String> xxx = new SimpleListProperty<>(FXCollections.observableArrayList());
NOTE: Using a simple ObservableList
does not work for me because I'm using Property
methods (e.g.: getBean()
)