FileTreeModel Multiple Roots

java, jtree, swing

Solution

A `TreeModel` can only have one root node, but you can use `JTree.setRootVisible()` to hide the root node when displaying the tree. Modify your model to have a virtual root node that contains each filesystem root (C:\, D:\, E:\, etc.), and call `JTree.setRootVisible(false)` on your JTree.

Problem

I use this code here to create a file tree model. I want it to browse files. How can I add multiple roots? E.g. list C:/, D:/, E:/.

Original source