JavaFX - bind property to properties of every element in observable Collection

后端 未结 2 974
星月不相逢
星月不相逢 2020-12-15 12:29

Does exist any method which bind BooleanProperty to conjunction of every element in ObservableList?

ObservableList list;
list = FXColl         


        
2条回答
  •  佛祖请我去吃肉
    2020-12-15 13:04

    You can easily implement the method as follows:

    public static BooleanBinding conjunction(ObservableList list){   
      BooleanBinding and = new SimpleBooleanProperty(true).and(list.get(0));
      for(int i = 1; i < list.size(); i++){
        and = and.and(list.get(i));   
      }
      return and;
    }
    

提交回复
热议问题