【发布时间】:2014-02-28 09:17:51
【问题描述】:
我需要有关设置组合框 buttonCell 的帮助。 我使用一个组合框来显示来自可观察列表的数据,该列表包含来自具有两列“Step”和“NextStep”的表中的数据(NextStep 包含插入在列 Step 中的一个项目);我需要做的是显示带有“Step”列表的组合框列表单元和带有相对“NextStep”的按钮单元。现在,我可以正确看到列表单元,但我的按钮单元始终是空的。
代码:
// SET THE VALUE STEP TO THE LISTCELL
comboStatoSuccessivo.setCellFactory(new Callback<ListView<StatoEsiti>, ListCell<StatoEsiti>>() {
@Override public ListCell<StatoEsiti> call(ListView<StatoEsiti> p) {
return new ListCell<StatoEsiti>() {
@Override
protected void updateItem(StatoEsiti t, boolean bln) {
super.updateItem(t, bln);
if(t != null){
setText(t.statoProperty().getValue());
System.out.println("SET PROPERTY " + t.statoProperty().getValue());
} else {
setText(null);
}
}
};
}
});
// SET THE VALUE NEXTSTEP TO THE BUTTONCELL
comboStatoSuccessivo.setButtonCell(new ListCell<StatoEsiti>() {
@Override
protected void updateItem(StatoEsiti t, boolean bln) {
super.updateItem(t, bln);
if (t != null) { <<<<<<<<<<<<<<-------------ALWAYS NULL----WHY??????
setText(t.statoSuccessivoProperty().getValue());
System.out.println("SET PROPERTY BUTTONCELL " + t.statoSuccessivoProperty().getValue());
} else {
setText(null);
System.out.println("SET PROPERTY BUTTONCELL NULL");
}
}
});
提前致谢。
【问题讨论】: