CoerceBooleanProperty

Coerces a data-bound value (typically a string) to a boolean.

Say you want to design a carousel component. It should have an autoplay input that disables or enables the auto-play behavior.

You can now use it like this:

This indeed works, but it would be nice if the component consumers could also use it like this:

Unfortunately, at this point autoplay input equals to ‘’ which evaluates to false. This breaks the auto-play logic.

We can amend this with the use of coerceBooleanProperty :

Now the carousel auto-play will work as expected.

To have a better understanding of how the coerceBooleanProperty works, we can have a look at its specs: