开发者

Is there a fast way to expand many paths in a JTree?

开发者 https://www.devze.com 2023-01-26 15:46 出处:网络
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.

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

精彩评论

暂无评论...
验证码 换一张
取 消