Tino APCS

Properties in JavaFX

You already know about Wrapper classes in Java. As a reminder, a Wrapper class such as Integer encapsulate a primitive and gives it properties and methods.

A Property in JavaFX is an object that encapsulates data much like a Wrapper class. What makes Properties powerful is the fact that they also have built-in listener capability so that whenever the value of a Property changes, it will automatically run a method where you can do whatever you want in response to the change in value.

For example, you if you had the property DoubleProperty playerHealth; you could set it up so that whenever the value of playerHealth changes, say from 100 to 95, then a method would automatically be called to do some action. That is very powerful.

Here is a list of Properties in JavaFX.

Here are some Properties you will see often:

  • IntegerProperty
  • DoubleProperty
  • BooleanProperty
  • StringProperty
  • ListProperty

Last modified: March 03, 2023

Dark Mode

Outline