I want to create a simple ListView. I have figured out I can use the method setCellFactory() but I don\'t understand how to use them correctly. So far I have:
Thanks for previous answers. I miss the information that setCellValueFactory is not needed, but value assigned should also be done in setCellFactory. Here is my approach (much copied from previous solution).
public TreeTableColumn treetblcolHide;
...
treetblcolHide.setCellFactory(CheckBoxTreeTableCell.forTreeTableColumn(new Callback>() {
@Override
public ObservableValue call(final Integer param) {
final RowContainer rowitem = treetblcolHide.getTreeTableView().getTreeItem(param).getValue();
BooleanProperty observable = new SimpleBooleanProperty();
observable.addListener(new ChangeListener() {
@Override
public void changed(ObservableValue extends Boolean> observable, Boolean oldValue, Boolean newValue) {
rowitem.setHideMenuItem(newValue.toString());
}
}
);
observable.setValue(Boolean.parseBoolean(rowitem.getHideMenuItem()));
return observable ;
}
}));