
Swing dialog components like JOptionPane and JFileChooser are provided with i18n support for a number of languages. Still, there are times when the language we require is not supported or we want to have complete control on the displayed text. The following example code shows how we can override the default text using the UIManager and a ResourceBundle.
UIManager.put("OptionPane.yesButtonText", bundle.getString("common.yes"));
UIManager.put("OptionPane.cancelButtonText", bundle.getString("common.cancel"));
UIManager.put("OptionPane.noButtonText", bundle.getString("common.no"));
UIManager.put("OptionPane.okButtonText", bundle.getString("common.ok"));
UIManager.put("FileChooser.saveButtonText", bundle.getString("common.save"));
UIManager.put("FileChooser.cancelButtonText", bundle.getString("common.cancel"));
The strings that can be customized for a JOptionPane and a JFileChooser are:
OptionPane.yesButtonText
OptionPane.noButtonText
OptionPane.cancelButtonText
OptionPane.okButtonText
FileChooser.newFolderErrorText
FileChooser.newFolderErrorSeparator
FileChooser.fileDescriptionText
FileChooser.directoryDescriptionText
FileChooser.saveButtonText
FileChooser.openButtonText
FileChooser.saveDialogTitleText
FileChooser.openDialogTitleText
FileChooser.cancelButtonText
FileChooser.updateButtonText
FileChooser.helpButtonText
FileChooser.directoryOpenButtonText
FileChooser.saveButtonToolTipText
FileChooser.openButtonToolTipText
FileChooser.cancelButtonToolTipText
FileChooser.updateButtonToolTipText
FileChooser.helpButtonToolTipText
FileChooser.directoryOpenButtonToolTipText
Wednesday, December 26, 2007
i18n for standard Swing dialogs
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment