有没有一种快速的方法来扩展JTree中的许多路径? [英] Is there a fast way to expand many paths in a JTree?

查看:68
本文介绍了有没有一种快速的方法来扩展JTree中的许多路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个很大的JTree,我需要一次扩展成千上万个节点.现在,这需要很长时间.我认为这是因为它发出通知并为每个人完成所有工作.有什么方法可以告诉它批量扩展所有节点,以便以后只需要更新一次即可.

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

这篇关于有没有一种快速的方法来扩展JTree中的许多路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆