目录和文件的 FTP JTree

发布于 2024-10-27 16:14:14 字数 176 浏览 8 评论 0原文

我目前正在开发一个应用程序,允许人们从在线 FTP 存储库下载文件,我让它与 Apache Commons 完美连接,我唯一的麻烦是用它制作 JTable。

我知道如何创建 JTree,我的问题是在调用节点时添加节点(有人按加号图标,在子目录中加载文件)

还要确定它们是否是叶子...对不起,我迷路了眼下!

I'm currently developing an application that will allow people to download the files from the online FTP repository, I have it connecting perfectly with Apache Commons, My only trouble is making a JTable out of it.

I know how to create a JTree, My problem is adding the nodes when they are called (Someone presses the plus icon, Load files in sub directory)

Also determining whether they are leafs... I'm sorry, I'm so lost at the moment!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

百善笑为先 2024-11-03 16:14:14

如果是我,我会删除加号按钮,并在获取树将展开事件时加载子目录。

因此,您可以做的是填充顶级节点,并在其下方添加一个存根节点,并显示具有顶级节点(未展开)的树。当用户展开它时,您将收到树将展开的事件。查看子节点,看看它是否是一个 Stub 节点。如果它被删除,并使用 apache commons 加载子节点,填充每个子节点,并且每个子节点都有自己的存根节点。

什么是存根节点?只是一个以某种方式告诉您该节点是占位符的节点。这意味着您还没有尝试加载子项。这个 Node 类很可能是一个名为 StubNode 之类的特殊类。当然,您只需将存根节点添加到目录,而不是文件,因为您不会扩展文件。

http://www.java2s.com/Tutorial/Java/0240__Swing/TreeWillExpandListener.htm

If it were me, i'd remove the plus button, and just load sub directories when you get tree will expand events.

So What you could do, is populate the top level node, with a Stub node under it, and show the tree with the top level node, non-expanded. When the user expands it, you will get the tree will expand event. Look at the child, and see if it's a Stub node. If it is remove it, and use apache commons to load the children, populating each one, and each one with it's own stub node.

What is a stub node? Just a node that somehow tells you that this node is a placeholder. It means that you haven't tried to load children yet. Most likely this Node class will be a special class called StubNode or something. Of course you only need to add Stub nodes to directories, not files, as you won't be expanding files.

http://www.java2s.com/Tutorial/Java/0240__Swing/TreeWillExpandListener.htm
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文