问题描述
我正在创建一个应用程序,该应用程序在TreeView中始终具有3个级别的项目(根目录为4个),我需要它与复选框和叶项一起起作用,以使其成为radioButtons。
每个级别都有其自己的TreeItem类,但是它们都有共同的AbstractTreeItem。
直到现在,我一直在使用内置的CheckBoxTreeCell类。
我试图在TreeCellFactory中添加这样的RadioButtons,但是我缺少复选框和radioButtons之间的链接。
public class TreeCellEmulated extends CheckBoxTreeCell<String> {
private final RadioButton radio = new RadioButton();
@Override
public void updateItem(String item,boolean empty) {
super.updateItem(item,empty);
AbstractTreeItem item = (AbstractTreeItem) getTreeItem();
if(item != null) {
if(item.isLeaf()) {
if(item.getGroup() == null) {
ToggleGroup group = ((AbstractTreeItem) item.getParent()).getGroup();
item.setGroup(group);
radio.setToggleGroup(group);
radio.selectedproperty()...updateSelecte(newValue); //My attempt to change built-in checkBoxes
}
setGraphic(radio);
}
}
}
}
我想保留“外部自动选择”的功能(当您选择较高级别时,它会选择较低级别的所有内容。)并且当最低级别中没有选择radioButton时,它应该选择第一个条目。
最低级别的TreeItem包含具有布尔值的对象,我想在其中保存radioButton状态。 (这可以通过radioButton上的selectedProprety和changelistener完成。)
有什么建议可以改善/返工吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)