Issue
How to hide the value of a CheckBoxTreeItem?
mfbs.add(new CheckBoxTreeItem<String>(mfb.userId, new Label(mfb.userId + "-" + mfb.name), true));
The Label should be the caption of the CheckBoxTreeItem and the first argument mfb.userId
should not show up at all.
Thanks in advance
Solution
You can add a custom cell factory to your TreeView that disables the text:
TreeView<String> treeView;
CheckBoxTreeItem<String> root = new CheckBoxTreeItem<>("Not Visible", new Label("Visible"));
treeView.setRoot(root);
treeView.setCellFactory(e -> new CustomCheckBoxTreeCell());
public class CustomCheckBoxTreeCell extends CheckBoxTreeCell<String>{
public CustomCheckBoxTreeCell() {}
@Override
public void updateItem(String item, boolean empty) {
super.updateItem(item, empty);
if(!empty){
setText(null);
}
}
}
Answered By - William DeRaad