You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何为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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.16 19:22:24