问题
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:/.
回答1:
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.
来源:https://stackoverflow.com/questions/10501410/filetreemodel-multiple-roots