Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 632
Tony Eichelberger Avatar asked Sep 08 '10 21:09

Tony Eichelberger


2 Answers

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.

like image 127
Grey Teardrop Avatar answered Nov 11 '22 16:11

Grey Teardrop


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
like image 30
Colin Hebert Avatar answered Nov 11 '22 18:11

Colin Hebert