【发布时间】:2017-08-14 16:13:44
【问题描述】:
我有一个cuttingOperationComboBox ComboBox 和一个更改此 ComboBox 的项目和值的方法:
public void changeGlass(Glass newGlass)
{
ObservableList<Operation> list = new FilteredList<Operation>(ProductGlassCuttingUI.this.operationsDB.getOperationsList(), operation -> operation.getOperationType().toString().equals("RE") &&
operation.getGlassThickness() == newGlass.getGlassThickness());
if(!list.contains(this.cuttingOperationComboBox.getValue()))
cuttingOperationComboBox.setValue(list.get(0));
cuttingOperationComboBox.setItems(list);
}
我还将更改侦听器添加到 cuttingOperationComboBox.valueProperty()。
cuttingOperationComboBox.setValue(list.get(0)); 第一次触发它,这里一切都很好。但是当cuttingOperationComboBox.setItems(list); 触发更改侦听器时,尽管list 不为空,但其中的newValue 为null。此外,它仅在 ComboBox 可见时发生。更准确地说:cuttingOperationComboBox 在 TreeView 中显示为 TreeCell 图形的一部分。只要包含组合框的树视图节点折叠一切都可以,但是当我展开此节点并显示组合框时,就会出现上述问题。
有人知道我做错了什么吗?
【问题讨论】: