简体   繁体   English

更改 swing 中 JFileChooser 的外观

[英]change look and feel of JFileChooser in swing

My requirement is to add check box with every directory which is shown by JFileChooser.我的要求是为 JFileChooser 显示的每个目录添加复选框。 and give multi selection facility.并提供多选功能。

How can I achieve this?我怎样才能做到这一点?

JFileChooser has multi-selection built in ( setMultiSelectionEnabled() ). JFileChooser具有内置的多选功能( setMultiSelectionEnabled() )。 It doesn't use checkboxes, but you can select multiple items.它不使用复选框,但您可以 select 多个项目。

I think it can be done this way.我认为可以这样做。 Override MetalFileChooserUI.createList() and return your own custom list panel.覆盖MetalFileChooserUI.createList()并返回您自己的自定义列表面板。 Therein, add checkbox renderers to the items in your list.其中,将复选框渲染器添加到列表中的项目。

It would probably be easier to implement a custom component than alter a JFileChooser to support this (odd) requirement.实现自定义组件可能比更改JFileChooser来支持这个(奇怪的)要求更容易。 You might start with altering the component used in File Manager questions .您可以从更改文件管理器问题中使用的组件开始。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM