FileTreeModel Multiple Roots

依然范特西╮ 提交于 2021-02-07 08:57:20

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!