Supporting a language change in runtime

About this task

The Desktop uses the LanguageBox to support changing languages in runtime. The Java program requiring runtime localization must be a Listener of this class (using the mechanism that the Desktop provides to access a component by name) and change the DesktopLocale attribute of the Desktop class when a user selects an item in the LanguageBox.

To support switching languages during runtime, you must implement a method that executes when a user selects an item in the LanguageBox. This method must do the following:

Procedure

  1. Compare the value of the currentLanguage attribute with the language associated with the item selected in the LanguageBox.
  2. Create a Locale associated with the LanguageBox Item if the currentLanguage and the language are not the same.
  3. Change the Locale of the Desktop using the setDesktopLocale method.
  4. Call the regenerate method of the Desktop.

Results

See the Base Sample Application for an example of this behavior.