Nemo_Sol Nemo_Sol - 2 months ago 26
Java Question

How to bind Borderpane left property to node with JavaFX

How would I go about changing the borderpane's left property to a certain node whenever an integer variable is changed? What type of ObjectProperty do I use and how do I bind this as well as listen to the integer variable?

BorderPane border = new BorderPane();
IntegerProperty intProp = new SimpleIntegerProperty();

    () -> {
        int value = intProp.get();
        Node node = getLeftNodeForValue(value);
        return node ;

Where getLeftNodeForValue(...) is just a method that retrieves the appropriate node for a give integer value.

Alternatively, just use a listener instead of a binding:

intProp.addListener((obs, oldValue, newValue) ->