Swing JTree with Checkbox and JFileChooser

好久不见. 提交于 2019-12-02 03:33:17

问题


By using JFileChooser I am able to select file and folders getting JList with File Objects and I am showing it with checkbox. Now my requirement is like I want to show the selected file and folder in tree structure with checkbox and the checkbox should be only for root elements not for all child elements.

Example : For Example, I selected folders ABC and PQR which containt sub folders and few files now on UI It should be display

Checkbox1 ABC--
          --SubFolders
          .           --SubFolder
          .                      --Files
          --Files
Checkbox2 PQR--
          --SubFolders
          .           --SubFolder
          .                      --Files
          --Files

回答1:


Sounds a bit complicated... as far as the tree goes, there's an online post of code from the OReilly Java Cookbook that might help you:

http://java.codefetch.com/cache?url=http://examples.oreilly.com/javacook2/javacooksrc2.jar&path=gui/FileTree.java&lang=java&qy=jtree+file



来源:https://stackoverflow.com/questions/5637305/swing-jtree-with-checkbox-and-jfilechooser

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