I have a large JTree and I need to expand thousands of nodes all at once. Right now, that is taking a long time. I think it's because it's firing notifications and doing all the work for every one. Is there some way to tell it to expand all the nodes in a batch so it only has to update things once afterwards?
Or some other way to make expandin开发者_Go百科g lots of nodes in a batch faster?
Have you tried disabling the tree's event listeners? That way it won't fire off events every time you modify the tree. Something like this:
setVisible(false);
tree.removeTreeWillExpandListener(this);
tree.removeTreeSelectionListener(this);
//modify the tree
tree.addTreeSelectionListener(this);
tree.addTreeWillExpandListener(this);
setVisible(true);
精彩评论