JavaFX Properties


JavaFX Properties Tutorial:

JavaFX Properties are the improved version of the JavaBean concept.

It allows us to observe the value changes from controls and provide the capabilities to change or binding the values.

JavaFX properties are used in conjunction with binding.

Different Types of JavaFX Properties :

There are two types of JavaFX Properties :

  1. Read/Writable (Simple)
  2. Read-Only (ReadOnly)

Read/Writeable Properties :

Simple is used for read/writable properties for example SimpleStringProperty class.
These are the properties values that can be read and changed.

Creating a Read/write property :

StringProperty name =new SimpleStringProperty("");

We create a string-property using String Property class.
Here we use the sub-type SimpleStringProperty for creating a name read/writable property.

Creating a Read-Only Property:

StringProperty name =new ReadOnlyStringProperty("");

Here we create a string-property using String Property class.
And we use the sub-type ReadOnlyStringProperty for creating a name ReadOnly property.

Methods set() or setValue() method are used to modify the value of property.
To get the current value of the property we use get() or getValue() methods.

Javafx properties example :

Output :


Leave A Reply