How can I add localization to JFileChooser for a locale that is not supported by default?

后端 未结 2 1520
礼貌的吻别
礼貌的吻别 2020-12-06 02:28

The list of supported locales for User Interface Translation does not have all the languages I need to support. How can I add more languages for a JFileChooser

相关标签:
2条回答
  • 2020-12-06 02:41

    You can change the properties of your JFileChooser like FileChooser.openButtonText

    UIManager.put("FileChooser.acceptAllFileFilterText", "Directorios");
    UIManager.put("FileChooser.lookInLabelText", "Localização");
    UIManager.put("FileChooser.cancelButtonText", "Cancelar");
    UIManager.put("FileChooser.cancelButtonToolTipText", "Cancelar");
    UIManager.put("FileChooser.openButtonText", "Adicionar");
    UIManager.put("FileChooser.openButtonToolTipText", "Adicionar ficheiro(s)");
    UIManager.put("FileChooser.filesOfTypeLabelText", "Tipo");
    UIManager.put("FileChooser.fileNameLabelText", "Ficheiro(s)");
    UIManager.put("FileChooser.listViewButtonToolTipText", "Lista"); 
    UIManager.put("FileChooser.listViewButtonAccessibleName", "Lista"); 
    UIManager.put("FileChooser.detailsViewButtonToolTipText", "Detalhes");
    UIManager.put("FileChooser.detailsViewButtonAccessibleName", "Detalhes");
    UIManager.put("FileChooser.upFolderToolTipText", "Um nível acima"); 
    UIManager.put("FileChooser.upFolderAccessibleName", "Um nível acima"); 
    UIManager.put("FileChooser.homeFolderToolTipText", "Ambiente de Trabalho"); 
    UIManager.put("FileChooser.homeFolderAccessibleName", "Ambiente de Trabalho"); UIManager.put("FileChooser.fileNameHeaderText", "Nome"); 
    UIManager.put("FileChooser.fileSizeHeaderText", "Tamanho"); 
    UIManager.put("FileChooser.fileTypeHeaderText", "Tipo"); 
    UIManager.put("FileChooser.fileDateHeaderText", "Data"); 
    UIManager.put("FileChooser.fileAttrHeaderText", "Atributos"); 
    UIManager.put("FileChooser.openDialogTitleText","Adicionar Fotos");
    UIManager.put("FileChooser.readOnly", Boolean.TRUE);
    

    Resources :

    • Oracle.com - Swing
    0 讨论(0)
  • 2020-12-06 02:56

    In fact it is possible to use properties file to translate standard Swing strings. Just call

    UIManager.getDefaults().addResourceBundle("com.mypackage.messages");
    

    where com.mypackage.messages is a fully-qualified bundle base name.

    0 讨论(0)
提交回复
热议问题