Tag: i18n

Overriding Swing components labels

Posted by – April 17, 2008

Are you worried about how can you put some components like JOptionPane, JFileChooser or JColorChooser in your language? You can solve this issue easily! Just add this code at the start of your application:

1
    UIManager.getDefaults().addResourceBundle("com.company.YourBundle");

“com.company.YourBundle” is the basename of your properties file, that can be:

YourBundle.properties
YourBundle_en_US.properties
YourBundle_pt_BR.properties

Where YourBundle*.properties may contains:

FileChooser.openDialogTitleText=Abrir
FileChooser.saveDialogTitleText=Salvar
FileChooser.lookInLabelText=Examinar:
FileChooser.saveInLabelText=Salvar em:

OptionPane.yesButtonText=Sim
OptionPane.noButtonText=N\u00E3o
OptionPane.cancelButtonText=Cancelar

ColorChooser.rgbNameText=RGB
ColorChooser.rgbRedText=Vermelho
ColorChooser.sampleText=Texto de Exemplo Texto de Exemplo
ColorChooser.swatchesNameText=Paleta de cores
ColorChooser.swatchesRecentText=Recente:

Share