如何自定义JFileChooser [英] How To Customize A JFileChooser

查看:88
本文介绍了如何自定义JFileChooser的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想自定义我的JFileChooser,以便不要在底部说文件夹名称",而是将其设置为图片名称",而在文本字段中,我不想根据我的位置更改它.单击,我希望它始终保持空白.无论如何,我可以做到这一点.基本上,我只想自定义我的JFileChooser:

I want to customize my JFileChooser so that instead of saying "Folder Name" at the bottom I want to set it to say "Picture Name" and at the text field I don't want that to change based on where i'm clicking, i want it to just stay blank the whole time. Anyway I could do this. basically I just want to customize my JFileChooser:

推荐答案

文件选择器并非旨在通过这种方式进行定制.正确的解决方案是自定义文件选择器的用户界面.

The file chooser wasn't designed to be customized in this way. The proper solution would be to customize the UI of the file chooser.

对于黑客来说,您可以尝试使用Darryl的 Swing Utils 类.该示例显示您可以访问文本字段.一旦有了文本字段,就可以添加DocumentFilter来防止文档被更新.或者,您可以将字体颜色更改为白色,以便看不到文本.

For a hack you can try using Darryl's Swing Utils class. The example shows you can access the text field. Once you have the text field you could add a DocumentFilter to prevent the document from being updated. Or you could change the font color to white so you don't see the text.

访问标签的代码将是相似的.只需找到包含要更改的文本的标签即可.

The code to access the label would be similar. Just find the label containing the text you want to change.

这篇关于如何自定义JFileChooser的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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