Boolean operations

Boolean operations allow you to incorporate conditions directly into the binding.

First of all, there are BooleanExpression/BooleanBinding classes to represent observable boolean values. Then, to make if-then-else condition handlers, there are special methods in the Binding API:

when( CONDITION ) -> then( A ) -> otherwise( B )

Here, when, then, and otherwise are actual method names, not pseudocode. This construction means the following:

  • Listen to A and B
  • If A is changed and the CONDITION is true, update the bound value with A
  • If B is changed and the CONDITION is false, update the bound value with B

As an example, let's forget for a minute we have the min() method from the rectangles grid example and re-implement it using ...

Get Mastering JavaFX 10 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.