Localizing the JFileChooser “All Files” string

ぐ巨炮叔叔 提交于 2019-12-10 14:31:16

问题


I am working on a java application with a JFileChooser and the user is able to switch languages.

Locale.setDefault( Locale.ENGLISH );
JFileChooser chooser = new JFileChooser();
chooser.showOpenDialog( null );

Locale.setDefault( Locale.CHINA );
JFileChooser.setDefaultLocale( Locale.CHINA );
JFileChooser chinese_chooser = new JFileChooser();
chinese_chooser.showOpenDialog( null );

The second file chooser to appear is in Chinese except for the "All Files" string in the drop down box. If I comment out the first section of code the file chooser appears correctly with all the strings translated.

Is this a bug in java or do I need to set the locale somewhere else?

How can I get the translated file chooser to appear correctly?


回答1:


I found something that might help you here. Here's how you change the "All Files" string:

UIManager.put("FileChooser.acceptAllFileFilterText","abc4"); 

Just put this right before you set the default locale to Locale.CHINA. It's lame that it's not changed in the locale, but maybe that will give you the work around you need for this to work out for you.



来源:https://stackoverflow.com/questions/17050612/localizing-the-jfilechooser-all-files-string

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!