Nemo_Sol Nemo_Sol - 1 year ago 79
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?

Answer Source
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) -> 
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download