Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4884480

i18n - changes to default Locale not reflected in JOptionPane etc.

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_2000, windows_xp

      Description

      Name: rmT116609 Date: 06/26/2003


      FULL PRODUCT VERSION :
      java version "1.4.2-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-beta-b19)
      Java HotSpot(TM) Client VM (build 1.4.2-beta-b19, mixed mode)


      FULL OS VERSION :
      C:\>ver

      Microsoft Windows 2000 [Version 5.00.2195]

      A DESCRIPTION OF THE PROBLEM :
      If the default locale is set after calling a swing component that uses UIManager properties, such as JOptionPane, the old locale is used. There is no way to force the UIManager to clear its i18n cache.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      See the sample code. Re-setting the default locale does not cause re-loading of any i18n-specific captions such as Yes, No, Cancel, etc. for the JOptionPane. Reading through the UIManager source code it looks like there is no way to force re-loading of the i18n properties once the UIManager is initialised.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The first JOptionPane should have:
      Title: Wahlen Sie eine Option aus
      Message: Are you sure?
      Buttons: Ja, Nein, Abbrechen

      The second JOptionPane should have:
      Title: Select an Option
      Message: Are you sure?
      Buttons: Yes, No, Cancel

      ACTUAL -
      Both JOptionPanes are displayed with German text supplied by UIManager.
      If the two Locale.setDefault calls are swapped around in the above example, both JOptionPanes are displayed with English text supplied by UIManager.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package com.mycompany;

      import java.util.Locale;

      import javax.swing.JOptionPane;


      public class I18nBug {
          public static void main(String[] args) {
              Locale.setDefault(Locale.GERMAN);
              JOptionPane.showConfirmDialog(null, "Are you sure?");
              Locale.setDefault(Locale.ENGLISH);
              JOptionPane.showConfirmDialog(null, "Are you sure?");
              
              System.exit(0);
          }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      None known. The state of the UIManager inner classes responsible for caching is private, so cannot be set by a calling program.
      (Review ID: 189366)
      ======================================================================
      ###@###.### 10/13/04 18:48 GMT

        Attachments

          Activity

            People

            Assignee:
            alexsch Alexandr Scherbatiy
            Reporter:
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: