javafx Types of properties and naming


Example

Standard properties

Depending on the type of the property, there are up to 3 methods for a single property. Let <property> denote the name of a property and <Property> the name of the property with an uppercase first letter. And let T be the type of the property; for primitive wrappers we use the primitive type here, e.g. String for StringProperty and double for ReadOnlyDoubleProperty.

Method nameParametersReturn typePurpose
<property>Property()The property itself, e.g.
DoubleProperty, ReadOnlyStringProperty, ObjectProperty<VPos>
return the property itself for adding listeners / binding
get<Property>()Treturn the value wrapped in the property
set<Property>(T)voidset the value of the property

Note that the setter does not exist for readonly properties.

Readonly list properties

Readonly list properties are properties that provide only a getter method. The type of such a property is ObservableList, preferably with a type agrument specified. The value of this property never changes; the content of the ObservableList may be changed instead.

Readonly map properties

Similar to readonly list properties readonly map properties only provide a getter and the content may be modified instead of the property value. The getter returns a ObservableMap.