Sprache von Deutsch auf Englisch umstellen

antiautomatic

Grünschnabel
Hallo zusammen,
ich habe folgendes Problem:
Meine Anwendng ist komplett in englisch geschrieben. "Automatisch" erzeugte Fenster wie JFilechooser und JDialog werden aber komplett in deutsch dargestellt. Ich weiß, daß man die entsprechende Locale setzen muss, das funktioniert aber nicht. Ich hab es folgendermaßen probiert:

fc = new JFileChooser();
fc.setLocale(Locale.ENGLISH);

Vielleicht hat jemand eine funktionierende Lösung parat?
Danke

Manuel
 
Danke erstmal,
aber das ist noch nicht ganz was ich suche. Beim zweiten Link muss man bezahlen, um die Beispiele einzusehen, beim ersten geht es eher um Multilingual Applications.
Das brauche ich gar nicht. Mein Programm ist komplett englisch, allerdings werden Komponenten wie JFileChooser mit deutschen Buttons, Tooltips usw. angezeigt. Das würde ich gerne einmal beim Start meines Programms ändern, also die default Sprache auf englisch setzen. Mit

Locale.setDefault(Locale.ENGLISH);

funktioniert es nicht.
Danke

Manuel
 
Ich bin mir nicht 100% sicher ob das der Grund ist. Aber könnte es sein, das Deine Laufzeitumgebung die englischen Resourcebundels nicht hat?

vielleicht hilft Dir der Tipp
 
Hallo!

Versuchs mal damit:
Code:
package de.tutorials;
 
 import java.awt.BorderLayout;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 
 import javax.swing.JButton;
 import javax.swing.JComboBox;
 import javax.swing.JFileChooser;
 import javax.swing.JFrame;
 import javax.swing.UIManager;
 import javax.swing.plaf.ComponentUI;
 
 public class DynamicLanguageChangeExample extends JFrame {
 	private JFileChooser fileChooser;
 
 	private ComponentUI fileChooserComponentUI;
 
 	public DynamicLanguageChangeExample() {
 		super("DynamicLanguageChangeExample");
 		setDefaultCloseOperation(EXIT_ON_CLOSE);
 		fileChooser = new JFileChooser();
 		fileChooserComponentUI = UIManager.getUI(fileChooser);
 
 		final JComboBox cboLanguage = new JComboBox(new Object[]{"en", "de"});
 		JButton btnSwitchLanguage = new JButton("ok");
 		btnSwitchLanguage.addActionListener(new ActionListener() {
 			public void actionPerformed(ActionEvent e) {
 				Object selectedItem = cboLanguage.getSelectedItem();
 
 				if (selectedItem.equals("de")) {
 					UIManager
 		    		    	.put("FileChooser.lookInLabelText", "Verzeichnis:");
 				} else if (selectedItem.equals("en")) {
 		    	    UIManager.put("FileChooser.lookInLabelText", "Folder:");
 				}
 
 				fileChooser.updateUI();
 		        fileChooser.showOpenDialog(DynamicLanguageChangeExample.this);
 				System.out.println(fileChooser.getSelectedFile());
 
 			}
 		});
 		add(cboLanguage, BorderLayout.NORTH);
 		add(btnSwitchLanguage, BorderLayout.SOUTH);
 
 		pack();
 		setVisible(true);
 	}
 
 	public static void main(String[] args) {
 		new DynamicLanguageChangeExample();
 	}
 }

(Auszug der) Konstanten:

lookInLabel
lookInLabelMnemonic
lookInLabelText
saveInLabelText
fileNameLabelMnemonic
fileNameLabelText
filesOfTypeLabelMnemonic
filesOfTypeLabelText
upFolderToolTipText
homeFolderToolTipText
newFolderToolTipText
listViewButtonToolTipText
detailsViewButtonToolTipText
fileNameHeaderText
fileSizeHeaderText
fileTypeHeaderText
fileDateHeaderText
fileAttrHeaderText

Gruß Tom
 
Hi Tom, hi community,

wo kann ich die komplette Liste der UIDefault Table einsehen?
Ich hab mir schon die Finger wund gesucht ;-)

Ich möchte nämlich einen kompletten Filechooser mit der UIDeafaultstable lokalisierbar machen (inkl. aller tooltips und was es auch sonst noch geben mag)

grüße
Hendrik
 
Hallo!

Ich denke das hier sind alle(?)
Code:
  AuditoryCues.allAuditoryCues
  AuditoryCues.cueList
  AuditoryCues.defaultCueList
  AuditoryCues.noAuditoryCues
  Button.background
  Button.border
  Button.darkShadow
  Button.defaultButtonFollowsFocus
  Button.disabledText
  Button.disabledToolBarBorderBackground
  Button.focus
  Button.focusInputMap
  Button.font
  Button.foreground
  Button.gradient
  Button.highlight
  Button.light
  Button.margin
  Button.rollover
  Button.rolloverIconType
  Button.select
  Button.shadow
  Button.textIconGap
  Button.textShiftOffset
  Button.toolBarBorderBackground
  ButtonUI
  CheckBox.background
  CheckBox.border
  CheckBox.disabledText
  CheckBox.focus
  CheckBox.focusInputMap
  CheckBox.font
  CheckBox.foreground
  CheckBox.gradient
  CheckBox.icon
  CheckBox.margin
  CheckBox.rollover
  CheckBox.textIconGap
  CheckBox.textShiftOffset
  CheckBoxMenuItem.acceleratorFont
  CheckBoxMenuItem.acceleratorForeground
  CheckBoxMenuItem.acceleratorSelectionForeground
  CheckBoxMenuItem.arrowIcon
  CheckBoxMenuItem.background
  CheckBoxMenuItem.border
  CheckBoxMenuItem.borderPainted
  CheckBoxMenuItem.checkIcon
  CheckBoxMenuItem.commandSound
  CheckBoxMenuItem.disabledForeground
  CheckBoxMenuItem.font
  CheckBoxMenuItem.foreground
  CheckBoxMenuItem.gradient
  CheckBoxMenuItem.margin
  CheckBoxMenuItem.selectionBackground
  CheckBoxMenuItem.selectionForeground
  CheckBoxMenuItemUI
  CheckBoxUI
  Checkbox.select
  ColorChooser.background
  ColorChooser.font
  ColorChooser.foreground
  ColorChooser.swatchesDefaultRecentColor
  ColorChooser.swatchesRecentSwatchSize
  ColorChooser.swatchesSwatchSize
  ColorChooserUI
  ComboBox.ancestorInputMap
  ComboBox.background
  ComboBox.buttonBackground
  ComboBox.buttonDarkShadow
  ComboBox.buttonHighlight
  ComboBox.buttonShadow
  ComboBox.disabledBackground
  ComboBox.disabledForeground
  ComboBox.font
  ComboBox.foreground
  ComboBox.selectionBackground
  ComboBox.selectionForeground
  ComboBox.timeFactor
  ComboBoxUI
  Desktop.ancestorInputMap
  Desktop.background
  DesktopIcon.background
  DesktopIcon.border
  DesktopIcon.font
  DesktopIcon.foreground
  DesktopIcon.width
  DesktopIconUI
  DesktopPaneUI
  EditorPane.background
  EditorPane.border
  EditorPane.caretBlinkRate
  EditorPane.caretForeground
  EditorPane.focusInputMap
  EditorPane.font
  EditorPane.foreground
  EditorPane.inactiveForeground
  EditorPane.margin
  EditorPane.selectionBackground
  EditorPane.selectionForeground
  EditorPaneUI
  FileChooser.ancestorInputMap
  FileChooser.detailsViewIcon
  FileChooser.fileNameLabelMnemonic
  FileChooser.filesOfTypeLabelMnemonic
  FileChooser.homeFolderIcon
  FileChooser.listViewIcon
  FileChooser.lookInLabelMnemonic
  FileChooser.newFolderIcon
  FileChooser.readOnly
  FileChooser.upFolderIcon
  FileChooser.useSystemExtensionHiding
  FileChooser.usesSingleFilePane
  FileChooserUI
  FileView.computerIcon
  FileView.directoryIcon
  FileView.fileIcon
  FileView.floppyDriveIcon
  FileView.hardDriveIcon
  FormattedTextField.background
  FormattedTextField.border
  FormattedTextField.caretBlinkRate
  FormattedTextField.caretForeground
  FormattedTextField.focusInputMap
  FormattedTextField.font
  FormattedTextField.foreground
  FormattedTextField.inactiveBackground
  FormattedTextField.inactiveForeground
  FormattedTextField.margin
  FormattedTextField.selectionBackground
  FormattedTextField.selectionForeground
  FormattedTextFieldUI
  InternalFrame.activeTitleBackground
  InternalFrame.activeTitleForeground
  InternalFrame.activeTitleGradient
  InternalFrame.border
  InternalFrame.borderColor
  InternalFrame.borderDarkShadow
  InternalFrame.borderHighlight
  InternalFrame.borderLight
  InternalFrame.borderShadow
  InternalFrame.closeIcon
  InternalFrame.closeSound
  InternalFrame.icon
  InternalFrame.iconifyIcon
  InternalFrame.inactiveTitleBackground
  InternalFrame.inactiveTitleForeground
  InternalFrame.maximizeIcon
  InternalFrame.maximizeSound
  InternalFrame.minimizeIcon
  InternalFrame.minimizeSound
  InternalFrame.optionDialogBorder
  InternalFrame.paletteBorder
  InternalFrame.paletteCloseIcon
  InternalFrame.paletteTitleHeight
  InternalFrame.restoreDownSound
  InternalFrame.restoreUpSound
  InternalFrame.titleFont
  InternalFrameUI
  Label.background
  Label.disabledForeground
  Label.disabledShadow
  Label.font
  Label.foreground
  LabelUI
  List.background
  List.cellRenderer
  List.focusCellHighlightBorder
  List.focusInputMap
  List.focusInputMap.RightToLeft
  List.font
  List.foreground
  List.selectionBackground
  List.selectionForeground
  List.timeFactor
  ListUI
  Menu.acceleratorFont
  Menu.acceleratorForeground
  Menu.acceleratorSelectionForeground
  Menu.arrowIcon
  Menu.background
  Menu.border
  Menu.borderPainted
  Menu.checkIcon
  Menu.crossMenuMnemonic
  Menu.disabledForeground
  Menu.font
  Menu.foreground
  Menu.margin
  Menu.menuPopupOffsetX
  Menu.menuPopupOffsetY
  Menu.opaque
  Menu.selectionBackground
  Menu.selectionForeground
  Menu.shortcutKeys
  Menu.submenuPopupOffsetX
  Menu.submenuPopupOffsetY
  MenuBar.background
  MenuBar.border
  MenuBar.borderColor
  MenuBar.font
  MenuBar.foreground
  MenuBar.gradient
  MenuBar.highlight
  MenuBar.shadow
  MenuBar.windowBindings
  MenuBarUI
  MenuItem.acceleratorDelimiter
  MenuItem.acceleratorFont
  MenuItem.acceleratorForeground
  MenuItem.acceleratorSelectionForeground
  MenuItem.arrowIcon
  MenuItem.background
  MenuItem.border
  MenuItem.borderPainted
  MenuItem.checkIcon
  MenuItem.commandSound
  MenuItem.disabledForeground
  MenuItem.font
  MenuItem.foreground
  MenuItem.margin
  MenuItem.selectionBackground
  MenuItem.selectionForeground
  MenuItemUI
  MenuUI
  OptionPane.background
  OptionPane.border
  OptionPane.buttonAreaBorder
  OptionPane.buttonClickThreshhold
  OptionPane.errorDialog.border.background
  OptionPane.errorDialog.titlePane.background
  OptionPane.errorDialog.titlePane.foreground
  OptionPane.errorDialog.titlePane.shadow
  OptionPane.errorIcon
  OptionPane.errorSound
  OptionPane.font
  OptionPane.foreground
  OptionPane.informationIcon
  OptionPane.informationSound
  OptionPane.messageAreaBorder
  OptionPane.messageForeground
  OptionPane.minimumSize
  OptionPane.questionDialog.border.background
  OptionPane.questionDialog.titlePane.background
  OptionPane.questionDialog.titlePane.foreground
  OptionPane.questionDialog.titlePane.shadow
  OptionPane.questionIcon
  OptionPane.questionSound
  OptionPane.warningDialog.border.background
  OptionPane.warningDialog.titlePane.background
  OptionPane.warningDialog.titlePane.foreground
  OptionPane.warningDialog.titlePane.shadow
  OptionPane.warningIcon
  OptionPane.warningSound
  OptionPane.windowBindings
  OptionPaneUI
  Panel.background
  Panel.font
  Panel.foreground
  PanelUI
  PasswordField.background
  PasswordField.border
  PasswordField.caretBlinkRate
  PasswordField.caretForeground
  PasswordField.focusInputMap
  PasswordField.font
  PasswordField.foreground
  PasswordField.inactiveBackground
  PasswordField.inactiveForeground
  PasswordField.margin
  PasswordField.selectionBackground
  PasswordField.selectionForeground
  PasswordFieldUI
  PopupMenu.background
  PopupMenu.border
  PopupMenu.consumeEventOnClose
  PopupMenu.font
  PopupMenu.foreground
  PopupMenu.popupSound
  PopupMenu.selectedWindowInputMapBindings
  PopupMenu.selectedWindowInputMapBindings.RightToLeft
  PopupMenuSeparatorUI
  PopupMenuUI
  ProgressBar.background
  ProgressBar.border
  ProgressBar.cellLength
  ProgressBar.cellSpacing
  ProgressBar.cycleTime
  ProgressBar.font
  ProgressBar.foreground
  ProgressBar.horizontalSize
  ProgressBar.repaintInterval
  ProgressBar.selectionBackground
  ProgressBar.selectionForeground
  ProgressBar.verticalSize
  ProgressBarUI
  RadioButton.background
  RadioButton.border
  RadioButton.darkShadow
  RadioButton.disabledText
  RadioButton.focus
  RadioButton.focusInputMap
  RadioButton.font
  RadioButton.foreground
  RadioButton.gradient
  RadioButton.highlight
  RadioButton.icon
  RadioButton.light
  RadioButton.margin
  RadioButton.rollover
  RadioButton.select
  RadioButton.shadow
  RadioButton.textIconGap
  RadioButton.textShiftOffset
  RadioButtonMenuItem.acceleratorFont
  RadioButtonMenuItem.acceleratorForeground
  RadioButtonMenuItem.acceleratorSelectionForeground
  RadioButtonMenuItem.arrowIcon
  RadioButtonMenuItem.background
  RadioButtonMenuItem.border
  RadioButtonMenuItem.borderPainted
  RadioButtonMenuItem.checkIcon
  RadioButtonMenuItem.commandSound
  RadioButtonMenuItem.disabledForeground
  RadioButtonMenuItem.font
  RadioButtonMenuItem.foreground
  RadioButtonMenuItem.gradient
  RadioButtonMenuItem.margin
  RadioButtonMenuItem.selectionBackground
  RadioButtonMenuItem.selectionForeground
  RadioButtonMenuItemUI
  RadioButtonUI
  RootPane.ancestorInputMap
  RootPane.colorChooserDialogBorder
  RootPane.defaultButtonWindowKeyBindings
  RootPane.errorDialogBorder
  RootPane.fileChooserDialogBorder
  RootPane.frameBorder
  RootPane.informationDialogBorder
  RootPane.plainDialogBorder
  RootPane.questionDialogBorder
  RootPane.warningDialogBorder
  RootPaneUI
  ScrollBar.allowsAbsolutePositioning
  ScrollBar.ancestorInputMap
  ScrollBar.ancestorInputMap.RightToLeft
  ScrollBar.background
  ScrollBar.darkShadow
  ScrollBar.foreground
  ScrollBar.gradient
  ScrollBar.highlight
  ScrollBar.maximumThumbSize
  ScrollBar.minimumThumbSize
  ScrollBar.shadow
  ScrollBar.thumb
  ScrollBar.thumbDarkShadow
  ScrollBar.thumbHighlight
  ScrollBar.thumbShadow
  ScrollBar.track
  ScrollBar.trackHighlight
  ScrollBar.width
  ScrollBarUI
  ScrollPane.ancestorInputMap
  ScrollPane.ancestorInputMap.RightToLeft
  ScrollPane.background
  ScrollPane.border
  ScrollPane.font
  ScrollPane.foreground
  ScrollPaneUI
  Separator.background
  Separator.foreground
  Separator.highlight
  Separator.shadow
  SeparatorUI
  Slider.altTrackColor
  Slider.background
  Slider.focus
  Slider.focusGradient
  Slider.focusInputMap
  Slider.focusInputMap.RightToLeft
  Slider.focusInsets
  Slider.foreground
  Slider.gradient
  Slider.highlight
  Slider.horizontalSize
  Slider.horizontalThumbIcon
  Slider.majorTickLength
  Slider.minimumHorizontalSize
  Slider.minimumVerticalSize
  Slider.shadow
  Slider.tickColor
  Slider.trackWidth
  Slider.verticalSize
  Slider.verticalThumbIcon
  SliderUI
  Spinner.ancestorInputMap
  Spinner.arrowButtonBorder
  Spinner.arrowButtonInsets
  Spinner.arrowButtonSize
  Spinner.background
  Spinner.border
  Spinner.editorBorderPainted
  Spinner.font
  Spinner.foreground
  SpinnerUI
  SplitPane.ancestorInputMap
  SplitPane.background
  SplitPane.border
  SplitPane.centerOneTouchButtons
  SplitPane.darkShadow
  SplitPane.dividerFocusColor
  SplitPane.dividerSize
  SplitPane.highlight
  SplitPane.oneTouchButtonsOpaque
  SplitPane.shadow
  SplitPaneDivider.border
  SplitPaneDivider.draggingColor
  SplitPaneUI
  TabbedPane.ancestorInputMap
  TabbedPane.background
  TabbedPane.borderHightlightColor
  TabbedPane.contentAreaColor
  TabbedPane.contentBorderInsets
  TabbedPane.contentOpaque
  TabbedPane.darkShadow
  TabbedPane.focus
  TabbedPane.focusInputMap
  TabbedPane.font
  TabbedPane.foreground
  TabbedPane.highlight
  TabbedPane.light
  TabbedPane.selectHighlight
  TabbedPane.selected
  TabbedPane.selectedTabPadInsets
  TabbedPane.shadow
  TabbedPane.tabAreaBackground
  TabbedPane.tabAreaInsets
  TabbedPane.tabInsets
  TabbedPane.tabRunOverlay
  TabbedPane.tabsOpaque
  TabbedPane.tabsOverlapBorder
  TabbedPane.textIconGap
  TabbedPane.unselectedBackground
  TabbedPaneUI
  Table.ancestorInputMap
  Table.ancestorInputMap.RightToLeft
  Table.background
  Table.focusCellBackground
  Table.focusCellForeground
  Table.focusCellHighlightBorder
  Table.font
  Table.foreground
  Table.gridColor
  Table.scrollPaneBorder
  Table.selectionBackground
  Table.selectionForeground
  TableHeader.background
  TableHeader.cellBorder
  TableHeader.font
  TableHeader.foreground
  TableHeaderUI
  TableUI
  TextArea.background
  TextArea.border
  TextArea.caretBlinkRate
  TextArea.caretForeground
  TextArea.focusInputMap
  TextArea.font
  TextArea.foreground
  TextArea.inactiveForeground
  TextArea.margin
  TextArea.selectionBackground
  TextArea.selectionForeground
  TextAreaUI
  TextField.background
  TextField.border
  TextField.caretBlinkRate
  TextField.caretForeground
  TextField.darkShadow
  TextField.focusInputMap
  TextField.font
  TextField.foreground
  TextField.highlight
  TextField.inactiveBackground
  TextField.inactiveForeground
  TextField.light
  TextField.margin
  TextField.selectionBackground
  TextField.selectionForeground
  TextField.shadow
  TextFieldUI
  TextPane.background
  TextPane.border
  TextPane.caretBlinkRate
  TextPane.caretForeground
  TextPane.focusInputMap
  TextPane.font
  TextPane.foreground
  TextPane.inactiveForeground
  TextPane.margin
  TextPane.selectionBackground
  TextPane.selectionForeground
  TextPaneUI
  TitledBorder.border
  TitledBorder.font
  TitledBorder.titleColor
  ToggleButton.background
  ToggleButton.border
  ToggleButton.darkShadow
  ToggleButton.disabledText
  ToggleButton.focus
  ToggleButton.focusInputMap
  ToggleButton.font
  ToggleButton.foreground
  ToggleButton.gradient
  ToggleButton.highlight
  ToggleButton.light
  ToggleButton.margin
  ToggleButton.select
  ToggleButton.shadow
  ToggleButton.textIconGap
  ToggleButton.textShiftOffset
  ToggleButtonUI
  ToolBar.ancestorInputMap
  ToolBar.background
  ToolBar.border
  ToolBar.borderColor
  ToolBar.darkShadow
  ToolBar.dockingBackground
  ToolBar.dockingForeground
  ToolBar.floatingBackground
  ToolBar.floatingForeground
  ToolBar.font
  ToolBar.foreground
  ToolBar.highlight
  ToolBar.isRollover
  ToolBar.light
  ToolBar.nonrolloverBorder
  ToolBar.rolloverBorder
  ToolBar.separatorSize
  ToolBar.shadow
  ToolBarSeparatorUI
  ToolBarUI
  ToolTip.background
  ToolTip.backgroundInactive
  ToolTip.border
  ToolTip.borderInactive
  ToolTip.font
  ToolTip.foreground
  ToolTip.foregroundInactive
  ToolTip.hideAccelerator
  ToolTipUI
  Tree.ancestorInputMap
  Tree.background
  Tree.changeSelectionWithFocus
  Tree.closedIcon
  Tree.collapsedIcon
  Tree.drawsFocusBorderAroundIcon
  Tree.editorBorder
  Tree.expandedIcon
  Tree.focusInputMap
  Tree.focusInputMap.RightToLeft
  Tree.font
  Tree.foreground
  Tree.hash
  Tree.leafIcon
  Tree.leftChildIndent
  Tree.line
  Tree.lineTypeDashed
  Tree.openIcon
  Tree.paintLines
  Tree.rightChildIndent
  Tree.rowHeight
  Tree.scrollsOnExpand
  Tree.selectionBackground
  Tree.selectionBorderColor
  Tree.selectionForeground
  Tree.textBackground
  Tree.textForeground
  Tree.timeFactor
  TreeUI
  Viewport.background
  Viewport.font
  Viewport.foreground
  ViewportUI
  activeCaption
  activeCaptionBorder
  activeCaptionText
  control
  controlDkShadow
  controlHighlight
  controlLtHighlight
  controlShadow
  controlText
  desktop
  inactiveCaption
  inactiveCaptionBorder
  inactiveCaptionText
  info
  infoText
  menu
  menuText
  scrollbar
  text
  textHighlight
  textHighlightText
  textInactiveText
  textText
  window
  windowBorder
  windowText

Gruss Tom
 
Danke Tom, wenn auch etwas verspätet ..

für meinen Filechooser habe ich letztendlich folgende Werte geändert:

FileChooser.fileNameLabelText
FileChooser.acceptAllFileFilterText
FileChooser.cancelButtonText
FileChooser.cancelButtonToolTipText
FileChooser.helpButtonText
FileChooser.helpButtonToolTipText
FileChooser.openButtonText
FileChooser.openButtonToolTipText
FileChooser.saveButtonText
FileChooser.saveButtonToolTipText
FileChooser.updateButtonText
FileChooser.updateButtonToolTipText
FileChooser.lookInLabelText
FileChooser.filesOfTypeLabelText
FileChooser.upFolderToolTipText
FileChooser.upFolderAccessibleName
FileChooser.DesktopFolderToolTipText
FileChooser.newFolderToolTipText
FileChooser.listViewButtonToolTipText
FileChooser.detailsViewButtonToolTipText
FileChooser.refreshActionLabelText
FileChooser.fileNameHeaderText
FileChooser.fileSizeHeaderText
FileChooser.fileTypeHeaderText
FileChooser.fileDateHeaderText
FileChooser.fileAttrHeaderText
FileChooser.sortMenuLabelText
FileChooser.openDialogTitleText

grüße
Hendrik
 
Hi,
der letzte Beitrag ist zwar schon ne weile her, aber trotzdem noch ne Antwort.


Code:
public void dateiAuswahl()   {
     Locale loc = Locale.ENGLISH; 
     JFileChooser.setDefaultLocale(loc);

     JFileChooser fc = new JFileChooser();
     //mache jetzt hier mit dem FileChooser was du willst
}

Und mit diesen beiden zusätzlichen Zeilen ist die Sprache nun auf Englisch :)
 
Zurück