我有一个包含checkboxTree的面板,我在打开面板时填充树,问题是当我需要在checkboxtree(大约4000)中选择很多项时,面板需要很长时间才能打开。 这是我的代码:
checkBoxTree.getCheckBoxTreeSelectionModel()setDigIn(真);
List<TreePath> paths = new ArrayList<TreePath>();
Enumeration<?> e = projectNode.breadthFirstEnumeration();
while (e.hasMoreElements())
{
IconNode node = (IconNode) e.nextElement();
if(node.isLeaf() && node.isSelected())
paths.add(new TreePath(node.getPath()));
}
TreePath[] array = new TreePath[paths.size()];
array = paths.toArray(new TreePath[0]);
checkBoxTree.getCheckBoxTreeSelectionModel().setSelectionPaths(array);
欢迎任何建议:),