JFileChooser 具有 Windows7 外观和感觉缺少按钮
我使用以下代码成功在 Windows 外观中创建了 JFileChooser
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) { }
但当 JFileChooser 出现时,它缺少文件名下拉菜单右侧的按钮。缺少的按钮是上一级、创建新文件夹、列表视图和详细信息视图按钮。
关于如何让它们回来有什么想法吗?
谢谢!
I succeeded in creating a JFileChooser
in the windows look and feel with the following code
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) { }
But when the JFileChooser comes up, it is missing buttons to the right of the drop-down menu of file names. The buttons that are missing are the up one level, create new Folder, list view, and details view buttons.
Any ideas on how I can get them back?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
JFileChooser
不是本机对话框。事实上,Swing 中什么都不是。如果您想要本机控件和对话框,则需要使用 SWT 而不是 Swing。
JFileChooser
isn't a native dialog. In fact, nothing in Swing is.If you want native controls and dialogs, you need to use SWT instead of Swing.
这似乎是我的计算机的一个特殊问题 - 当我在其他计算机上运行此程序时,会出现按钮。去算算吧。
It seems to be a particular problem with my computer - when I run this program on other computers, the buttons appear. Go figure.
我在 JRE 1.6.0 update 18 中遇到了同样的问题。显然,这是一个错误: 错误 ID:6840086 JFileChooser 在 Windows 7 上运行时右上角缺少图标。
该错误已在最新版本的 JRE:1.6.0 update 22 中修复。
I've got the same problem with JRE 1.6.0 update 18. Apparently, this is a bug: Bug ID: 6840086 JFileChooser lacks icons on top right when running on Windows 7.
This bug has been fixed in the latest version of JRE: 1.6.0 update 22.
你确定没有任何异常吗?也许将 e.printStackTrace() 放在 catch 块中只是为了 100% 确保没有异常
Are you sure there are no exceptions spitted out ? Perhaps put a e.printStackTrace() in the catch block just to be 100% sure that there are no exceptions
该问题在 1.6_0.25-b06 上仍然发生。我在 Oracle 论坛上创建了一个线程。
添加
我遇到此问题是因为 NetBeans 指向 JDK 1.6.13 目录。我必须安装 JDK 1.6.25 并更新 netbean 的配置文件+重新启动 NetBeans。
The issue still happens on 1.6_0.25-b06. I have created a thread on Oracle's forum.
ADDITION
I had this issue because NetBeans was pointing to JDK 1.6.13 directory. I had to install JDK 1.6.25 and update netbean's config file + reboot NetBeans.