使用Checkbox和JFileChooser摆动JTree [英] Swing JTree with Checkbox and JFileChooser

查看:154
本文介绍了使用Checkbox和JFileChooser摆动JTree的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过使用 JFileChooser 我可以选择使用文件对象获取JList的文件和文件夹,并使用复选框显示它。现在我的要求就像我想在树形结构中显示所选文件和文件夹的复选框,复选框应仅适用于根元素而不是所有子元素。

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.

示例:例如,我选择了文件夹ABC和PQR,其中包含子文件夹和少量文件
现在在UI上它应该显示

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


推荐答案

声音有点复杂......就树而言,OReilly Java Cookbook的在线帖子可能对你有帮助:

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

这篇关于使用Checkbox和JFileChooser摆动JTree的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆