如何为Java JFileChooser的「New Folder」添加法语翻译?
解决JFileChooser「New Folder」按钮的法语翻译问题
「New Folder」按钮对应的UIManager配置键是FileChooser.newFolderButtonText,你只需在现有代码中添加一行配置,将其值设为法语的「Nouveau dossier」即可。
另外注意你代码里的一处拼写错误:"Enregitrer"应修正为"Enregistrer"(法语“保存”的正确拼写)。
修改后的完整代码如下:
import javax.swing.JFileChooser; import javax.swing.UIManager; public class JFileChooserTest { public static void main(String[] args) throws Exception { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); UIManager.put("FileChooser.acceptAllFileFilterText", "Tous les fichiers"); UIManager.put("FileChooser.directoryOpenButtonText", "Ouvrir"); UIManager.put("FileChooser.openButtonText", "Ouvrir"); UIManager.put("FileChooser.saveButtonText", "Enregistrer"); // 修正拼写错误 UIManager.put("FileChooser.cancelButtonText", "Annuler"); UIManager.put("FileChooser.lookInLabelText", "Organiser :"); UIManager.put("FileChooser.fileNameLabelText", "Nom du fichier :"); UIManager.put("FileChooser.filesOfTypeLabelText", "Type :"); // 添加New Folder按钮的法语翻译 UIManager.put("FileChooser.newFolderButtonText", "Nouveau dossier"); JFileChooser chooser = new JFileChooser(); chooser.setDialogTitle("Ouvrir"); chooser.showOpenDialog(null); } }
如果需要配置更多JFileChooser的法语文本,还可以参考这些常用键:
FileChooser.upFolderToolTipText:返回上一级文件夹的提示文本FileChooser.homeFolderToolTipText:回到主目录的提示文本FileChooser.listViewButtonToolTipText:列表视图按钮的提示文本FileChooser.detailsViewButtonToolTipText:详情视图按钮的提示文本
内容的提问来源于stack exchange,提问作者Rui Baptista
相关产品推荐
相关产品推荐

