What is the difference between set(String)
and setValue(String)
in the SimpleStringProperty
class?
I know that set(String)
is derived from StringPropertyBase
, but this makes me even more wonder, why there additionally is setValue(String)
?
set/setValue
andget/getValue
methods pairs exist to align Object properties with primitive types properties likeBooleanProperty
orDoubleProperty
:BooleanProperty:
DoubleProperty:
In these property classes
___Value
methods work with corresponding to type objects while direct methods work with primitive types.Looking in the code you may find a bit of a difference in the logic. For example,
DoubleProperty#setValue(null)
is equal toDoubleProperty#set(0.0)
(which was required by binding). So generally I'd advise to use set/get methods and leave setValue/getValue to binding needs as they may incorporate additional logic.For Object/String properties there is no difference between set and setValue methods.
StringProperty.java :
StringPropertyBase.java:
In common case, you can open sources from open javafx and see that.