BooleanBinding of multiple properties

2

I made the following structure so that when you make one of the components invisible, the others follow the same configuration.

A.visibleProperty().bindBidirectional(B.visibleProperty()); 
A.visibleProperty().bindBidirectional(C.visibleProperty());
A.visibleProperty().bindBidirectional(D.visibleProperty());'

It works perfectly though, I'd like to find a way to do this more directly, eg:

A.bindBidirectional(B.bindBidirectional(C));

something like that. If anyone knows how to help, please respond. Thank you.

    
asked by anonymous 12.02.2017 / 21:06

1 answer

1

There is no way to do this since the object has several properties that can be bound, so A.BindBidirectional (B.BindBidirectional (C)) the class would not know which attribute it should do the bind. But to make your job easier you can make a class that connects data.

public class BindUtil{
    public static void bindVisibleProperty(Node a, Node b){
        A.visibleProperty().bindBidirectional(B.visibleProperty()); 
    }

    ///... métodos que fazem  bind com outras propriedades
}

So just do it.

BindUtil.bindVisibleProperty(a, b);
    
13.02.2017 / 10:18