Arithmetic operations

JavaFX binding supports basic arithmetic operations such as add, subtract, divide, multiply, and negate.

You can find them in binding/expression classes related to Number:

DoubleExpression, FloatExpression, IntegerExpression, LongExpression

The base class is NumberExpression. There are several overloaded methods to support work with both Observable objects and constants.

The very basic add operation is defined in NumberExpression and takes NumberExpression as a parameter. Here comes a question of the exact type of the result such an operation will produce. The rule is the same as in Java—data type with most precision and capacity takes precedence:

Double > Float > Long > Integer

Both operands are checked according to ...

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.