嘿伙计们,我一直在努力寻找解决问题的方法。我想在我的 JavaFx 应用程序中实现 ControlsFX CheckTreeView。基本上我有一个字符串列表,其格式与网站上的导航栏相匹配。到目前为止,示例 Admin.Config.User 将是字符串之一。我已经解析了这些字符串并将它们转换为 LinkedHashMap,其中每个拥有孩子的父母都将存储每个孩子的列表和孩子的 CheckBoxTreeItem。
创建 CheckTreeView 对象时,您可以传递 Root CheckBoxTreeItem 或不带参数进行初始化。
我很难想象如何构建一个从底部到根 CheckBoxTreeItem 的树。
// Contains the Nodes with children and corresponding CheckBoxTreeItems
LinkedHashMap<String, LinkedHashMap<String, CheckBoxTreeItem<String>>> navPaths = new LinkedHashMap<String, LinkedHashMap<String, CheckBoxTreeItem<String>>>();
// Was thinking about using this as a check to make sure duplicates are not added
LinkedHasMap<String, String> alreadyAdded = new LinkedHashMap<String, String>
// Check Tree View
CheckTreeView<String> checkTreeView = new CheckTreeView<>();
for(String pathNode : navPaths.keySet()){
for(String childName : testPaths.get(pathNode).keySet()){
// Completely lost once I get here
}
}
// Set built root
//checkTreeView.setRoot();
我真的在这个概念上苦苦挣扎,以至于我还没有走得很远,如果看起来我没有付出任何努力,我深表歉意。在过去的 12 个小时里,我一直在思考这个概念,但我对此一无所知。如果有人可以为我提供一些帮助,那将非常感谢。