Whenever your software has to interact with users to display file system structures it would be helpful to do so using a visualization of a directory Tree.
When you use a JTree to display such tree structures you can provide its constructor with an implementation of an interface called TreeModel.
The TreeModel implementation below is running recursively through all sub directories in a provided root directory.
By implementing the method getChildCount to return a count greater than zero, it is indicating that each directory should be recursively searched for files (children) and more directories. Of course the other directories have to implemented accordingly.
I did not come up with this idea by myself, but found it on the internet. However, the versions I found on the internet have not been working properly, so I deceided to code one, that will work.
How to use this implementation of TreeModel
Below a little example code on how the above TreeModel implementation can be used.