Java Swing 的文件浏览器组件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7195495/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
File browser component for Java swing
提问by ring bearer
Has anyone come across a fully customizable (compatible with all standard LnF), fast file browser component for Java Swing ?
有没有人遇到过用于 Java Swing 的完全可定制(与所有标准 LnF 兼容)的快速文件浏览器组件?
I should be able to place this component to Netbeans UI palette and drag and drop in to any JPanel while designing the UI. Also it should support directory, single file, multiple file selection along with file type filtering. There must be something because I have seen this in applications like jEdit etc.
在设计 UI 时,我应该能够将此组件放置到 Netbeans UI 调色板并拖放到任何 JPanel 中。它还应该支持目录、单文件、多文件选择以及文件类型过滤。一定有什么,因为我已经在 jEdit 等应用程序中看到了这一点。
Note that I am not asking about a dialog box like JFileChooser instead a browser/explorer/tree-view like component.
请注意,我问的不是像 JFileChooser 这样的对话框,而是像浏览器/资源管理器/树视图这样的组件。
回答by Nate W.
Here's a relatively simple file system browser built in a JPanel
:
这是一个相对简单的文件系统浏览器,内置于JPanel
:
Here are a few more complex examples of a file browser with icons, popup menus, and tooltips.
These are all built in a JFrame
:
下面是一些带有图标、弹出菜单和工具提示的文件浏览器的更复杂示例。
这些都内置在一个JFrame
:
These examples probably aren't as customizable as you may want, but they're a pretty good starting point for adding new functionality.
这些示例可能不像您想要的那样可定制,但它们是添加新功能的一个很好的起点。
For further reading, Swing, Second Edition(Chapter 17) walks through implementing a JTree
component for browsing your file system complete with lazy loading, custom renders, popup menus, and tooltips.
If you'd like to see just the source, you can get it here.
为了进一步阅读,Swing,第二版(第 17 章)介绍了如何实现一个JTree
用于浏览文件系统的组件,包括延迟加载、自定义渲染、弹出菜单和工具提示。
如果您只想查看源代码,可以在此处获取。
There is also the FileBrothat you may want to take a look at. Perhaps you can use it, or at least borrow implementation details.
也有FileBro,你可能想看一看。也许你可以使用它,或者至少借用实现细节。
回答by Wajdy Essam
see DJ Project: http://djproject.sourceforge.net/ns/index.html