FileTreeModel Multiple Roots

I use this code here to create a file tree model. I want him to browse files. How to add some roots? For instance. list C: /, D: /, E: /.

+3
source share
1 answer

A TreeModelcan have only one root root, but you can use JTree.setRootVisible()to hide the root root when displaying the tree. Change the model to have a virtual root node that contains each root of the file system (C: \, D: \, E: \ etc.) and calls JTree.setRootVisible(false)on your JTree.

+8
source

All Articles