0

我有一个包含 checkboxTree 的面板,我在打开面板时填充树,问题是当我必须在 checkboxtree 中选择很多项目(大约 4000 个)时,面板需要很长时间才能打开。这是我的代码:

checkBoxTree.getCheckBoxTreeSelectionModel().setDigIn(true);

    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);

任何建议都将受到欢迎:) ,

4

0 回答 0