Java:嵌套树结构

发布于 2024-08-15 04:32:56 字数 210 浏览 1 评论 0原文

我正在寻找一种在 GUI 中创建嵌套树结构的方法。我有几个“盒子”,里面装有物品。我希望这些框在单击时折叠但展开,就像在侧边栏上导航文件夹的方式一样。我考虑的第一种方法是将“盒子”视为 JList,每个盒子中的项目存储在嵌套的 JList 中。这似乎是一种非常复杂且糟糕的方法。它还可以防止盒子在没有对动作监听器进行大量修改的情况下折叠。我希望有人可能知道一个可能用于显示此处可能使用的文件导航的 API。

I am looking for a way to create a nested tree structure in my GUI. I have a few "boxes" that have items in them. I would like the boxes to be collapsed but expanded when clicked on, like the way folders are navigated on the sidebar. The first way I considered was treating the "boxes" as JList, with the items in each box stored in a nested JList. This seems like a very complicated and poor way of doing it. It also prevents the boxes from being collapsible without extensive modifications to the actionlistener. I was hoping someone might know of an API perhaps for displaying file navigation that might be used here.

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

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

发布评论

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

评论(2

无声无音无过去 2024-08-22 04:32:56

听起来您正在寻找 JTree 。有一个使用 JTree 的教程

It sounds like you are looking for JTree. There is a tutorial on using JTree.

め可乐爱微笑 2024-08-22 04:32:56

也许您正在寻找类似这个的东西。

Perhaps you are looking for something like this.

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