Which algorithm should used for traversal a directory tree, which is used for GUI by using JTree?
• You should not traverse the directory tree at all. What you only need is to display the top-level nodes and find out which directory is non-empty. If it is not empty, put a dummy node under it, to make that node display correctly. When user clicks it, load the real data on as-leaded bases. • This is called Proxy Design Pattern; it saves your time and resources. Read GoF’s book for details. • I used working on millions history records tree in VC++. Should I traverse the entire tree, no matter DFS or BFS, my program would die, and I would have been fired. I used Proxy pattern, even I did not know the pattern name then. Open folder on demand. When user close a folder, I need to unload some tree nodes by choosing Least Recent Used (LRU) nodes and use a dummy nodes again to save system resources and memory. Never use Depth First Search (DFS) in GUI tree, please!