d********r 发帖数: 199 | 1 GUI新手的问题:
我有一个非常庞大的tree, 用类似于Windows File explorer的方式visually 显示出来。
但我不会一开始的时候全部显示(因为太大,太复杂了)。
只load一部分层次。
以后根据用户的需要,我会再更新一些层次(可能达到数千个)上的node
由于每改变node structure 一下,这个tree都会visually被刷新,
所以这个过程要长达好几分钟。
有没有办法可以让我在批处理地方式改变node structure,
然后在最后一次性的反映在屏幕上?
也就是说,我不希望在每一步都引起屏幕的相应变化。
偶是GUI新手,不知说清楚了没有。
谢了先。 |
F****n 发帖数: 3271 | 2 That's a classical Swing question:
1. You should implement your own TreeModel to allow on-demand load of data.
Do not use DefaultTreeModel and DefaultMutableTreeNode
2. The correct semantics of TreeModelEvent is the tricky part. Remember the
purpose of TreeModelListener is for TreeModel to inform JTree, so whenever a
TreeModelEvent is fired, your TreeModel already has new data and JTree
still has the old data. That will help you understand TreeModelEvent.
Basically you should specify the path (O
【在 d********r 的大作中提到】 : GUI新手的问题: : 我有一个非常庞大的tree, 用类似于Windows File explorer的方式visually 显示出来。 : 但我不会一开始的时候全部显示(因为太大,太复杂了)。 : 只load一部分层次。 : 以后根据用户的需要,我会再更新一些层次(可能达到数千个)上的node : 由于每改变node structure 一下,这个tree都会visually被刷新, : 所以这个过程要长达好几分钟。 : 有没有办法可以让我在批处理地方式改变node structure, : 然后在最后一次性的反映在屏幕上? : 也就是说,我不希望在每一步都引起屏幕的相应变化。
|
d********r 发帖数: 199 | 3 多谢指教。
不过由于俺是GUI新手,还是不太懂该怎么做。
既然你说:
=============================
every time you
=============================
那么如果我改变了上千个node,岂不是要fire 上千次change event?
有没有可能在全部改变的最后只fire一次呢?
或者在每次change的时候不改变屏幕显示也行,直到最后才wholely repaint一次。
能不能请大侠再具体点:
我的要求可以实现吗?如何实现?
.
the
a
your
you |
F****n 发帖数: 3271 | 4 You can only fire changes (can be more than one) under ONE parent at one
time, period.
【在 d********r 的大作中提到】 : 多谢指教。 : 不过由于俺是GUI新手,还是不太懂该怎么做。 : 既然你说: : ============================= : every time you : ============================= : 那么如果我改变了上千个node,岂不是要fire 上千次change event? : 有没有可能在全部改变的最后只fire一次呢? : 或者在每次change的时候不改变屏幕显示也行,直到最后才wholely repaint一次。 : 能不能请大侠再具体点:
|