I am asking because it seems to be a bit inconvenient when implementing ChangeListeners.
For example,
slider.valueProperty().addListener((property, oldValue, newValue)
-> message.setFont(new Font(newValue)));
does not work. I invite you find out the reason from the error message:
error: no suitable method found for addListener((property,[...]lue)))
slider.valueProperty().addListener((property, oldValue, newValue)
^
method Observable.addListener(InvalidationListener) is not applicable
(argument mismatch; incompatible parameter types in lambda expression)
method ObservableValue.addListener(ChangeListener<? super Number>) is not applicable
(argument mismatch; cannot type-check lambda expression with inferred parameter types
inferred types: ObservableValue<? extends Number>,Number,Number)
That's actually bogus. newValue is inferred to be Number, and Number doesn't auto-unbox. This works:
slider.valueProperty().addListener((property, oldValue, newValue)
-> message.setFont(new Font(newValue.doubleValue())));
So, that's all rather obscure. What was gained by having DoubleProperty implement Property<Number> and not Property<Double>?
Thanks,
Cay