Module javafx.base

Class Bindings

java.lang.Object
javafx.beans.binding.Bindings

public final class Bindings
extends Object
Bindings is a helper class with a lot of utility functions to create simple bindings.

Usually there are two possibilities to define the same operation: the Fluent API and the the factory methods in this class. This allows a developer to define complex expression in a way that is most easy to understand. For instance the expression result = a*b + c*d can be defined using only the Fluent API:

DoubleBinding result = a.multiply(b).add(c.multiply(d));

Or using only factory methods in Bindings:

NumberBinding result = add (multiply(a, b), multiply(c,d));

Or mixing both possibilities:

NumberBinding result = add (a.multiply(b), c.multiply(d));

The main difference between using the Fluent API and using the factory methods in this class is that the Fluent API requires that at least one of the operands is an Expression (see javafx.beans.binding). (Every Expression contains a static method that generates an Expression from an ObservableValue.)

Also if you watched closely, you might have noticed that the return type of the Fluent API is different in the examples above. In a lot of cases the Fluent API allows to be more specific about the returned type (see NumberExpression for more details about implicit casting.

Deploying an Application as a Module

If any class used in a select-binding (see the various select* methods) is in a named module, then it must be reflectively accessible to the javafx.base module. A class is reflectively accessible if the module opens the containing package to at least the javafx.base module.

For example, if com.foo.MyClass is in the foo.app module, the module-info.java might look like this:

module foo.app {
    opens com.foo to javafx.base;
}

Alternatively, a class is reflectively accessible if the module exports the containing package unconditionally.

Since:
JavaFX 2.0
See Also:
Binding, NumberBinding