I have a special case where I want to add a listener to a visible property, and then have the listener removed when the property is no longer visible. I only want the listener to fire one time and then be removed.
ie
ChangeListener<Boolean> listener= (obs, ov, nv) -> {
if(!nv){
//do my processing
node.visibleProperty().removeListener(listener); }
}
};
node.visibleProperty().addListener(listener);
However it tells me that the variable listener may not have been initialized. If I try by making it null, then creating it, it complains that it is not effectively final
Is this possible?