约束观察者<;复选框>;到HBox';JavaFX中的儿童?
我希望能够做一些事情,比如:约束观察者<;复选框>;到HBox';JavaFX中的儿童?,java,javafx,Java,Javafx,我希望能够做一些事情,比如: ObservableList<CheckBox> checkboxes = ...; HBox hbox = new HBox(); hbox.childrenProperty.bind(checkboxes); observeList复选框=。。。; HBox HBox=新的HBox(); hbox.childrenProperty.bind(复选框); 但似乎没有childrenProperty。是否有可能以某种方式(简单且惯用的方式)将HBox
ObservableList<CheckBox> checkboxes = ...;
HBox hbox = new HBox();
hbox.childrenProperty.bind(checkboxes);
observeList复选框=。。。;
HBox HBox=新的HBox();
hbox.childrenProperty.bind(复选框);
但似乎没有childrenProperty
。是否有可能以某种方式(简单且惯用的方式)将HBox(或任何其他布局)的元素绑定到ObservableList
我试图“解决”的问题是不必在视图上有这种逻辑——我想进行这种映射,这样我就可以将视图控件映射到ViewModel的属性/绑定,并将所有逻辑保持在该级别
谢谢经过反复思考,我终于找到了一种方法:
ObservableList<CheckBox> checkboxes = ...;
Bindings.bindContent(hbox.getChildren(), checkboxes);
observeList复选框=。。。;
Bindings.bindContent(hbox.getChildren(),复选框);
使用监听器进行绑定怎么样:复选框。addListener((ListChangeListener.change)并自己实现所有更新逻辑?我期待更高层次的东西。