I want to support different languages in my Java application.
For selecting files I use JFileChooser, which seems to use the language
defined for the underlying operating system.
I tried to change it with the methode setLocale(Locale l) inherited from
java.awt.Component. But it doesn't work.
What's wrong? I assume there is a way to switch between languages. If not,
how can I change all the text messages 'manually'? (I found some methodes to
do that, for example chooser.setApproveButtonText("Open"). May I am wrong
but I think there are not enough such methodes to change all messages.)
Thank's in advance,
Matthias
JFileChooser chooser = new JFileChooser();
chooser.setLocale(Locale.ENGLISH);
int returnVal = chooser.showOpenDialog(this);
> I want to support different languages in my Java application.
> For selecting files I use JFileChooser, which seems to use the
> language defined for the underlying operating system.
> I tried to change it with the methode setLocale(Locale l)
> inherited from java.awt.Component. But it doesn't work.
This has been discussed a lot in this group. You need to set some
properties. See old postings for the details.
HH
Matthias
"Harald Hein" <speec...@gmx.de> schrieb im Newsbeitrag
news:Xns93366E1A...@194.97.5.9...
public void buildMainWindow() {
try {
Locale myLocale = Locale.getDefault();
////////////////////////////////////////////////////////////////////////////
/////
// Default locale is english, if there is polish we need to
change JFileChooser
// Java doesn't allow for easy changes of JFileChooser so this
is quick hack
if (myLocale.getLanguage().equals("pl")) {
UIManager.put("FileChooser.openButtonText","Otwórz");
UIManager.put("FileChooser.cancelButtonText","Anuluj");
UIManager.put("FileChooser.saveButtonText","Zapisz");
UIManager.put("FileChooser.cancelButtonToolTipText",
"Anulowanie operacji");
UIManager.put("FileChooser.saveButtonToolTipText", "Zapis
danych do pliku");
UIManager.put("FileChooser.openButtonToolTipText", "Przejdz
do katalogu");
UIManager.put("FileChooser.lookInLabelText", "Szukaj w :");
UIManager.put("FileChooser.fileNameLabelText", "Plik:");
UIManager.put("FileChooser.filesOfTypeLabelText", "Pliki
typu:");
UIManager.put("FileChooser.upFolderToolTipText", "Do góry");
UIManager.put("FileChooser.homeFolderToolTipText", "Glówny
pulpit");
UIManager.put("FileChooser.newFolderToolTipText", "Nowy
folder");
UIManager.put("FileChooser.listViewButtonToolTipText",
"Lista");
UIManager.put("FileChooser.detailsViewButtonToolTipText",
"Szczególy");
}
}
java -Duser.langauge=en myMainClass
JFileChooser uses the languaged specified by this propeterty. Setting the
property at runtime will not work.
Thomas
Matthias Weise schrieb:
By the way I have translations for polish, so I consider to support polish
as well :-)
Best wishes,
Matthias
> I have access to less than 400 postings in this group.
Learn to use groups.google.com
HH