I would like to create a JTree which reflect directory structure but is loaded succesive.
I have dir structure:
c:\root
-------\dir1
------------\file1
------------\file2
-------\dir2
I know how to load to JTree node structure of directories of first level (dir1, dir2). But i don't want to search files in each directory only when user will expand specific node in order to save time and resources.
Because of above i would like to add plus icon (or equivalent for particular java style) to each node even if it will be empty, in order to suggest user in this direcory can be files. Also when user will expand node (and search will be performed) when dir is empty i would like to remove any icon.
Is any way to do it?
I think DefaultTreeModel#setAsksAllowsChildren(boolean) is what you are looking for.