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

Swing rendering error for Turkish locale on XP look and feel

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b03
    • CPU:
      x86
    • OS:
      windows_xp

      Description

      FULL PRODUCT VERSION :
      java version "1.5.0_01"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)
      Java HotSpot(TM) Client VM (build 1.5.0_01-b08, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP SP1 [version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      JRadioButtons are rendered without the radio button part when running with a default locale set to tr_TR and the Windows look and feel selected.

      The problem only exists when Windows is run with the Windows XP layout. JRadioButtons display correct when the Windows Classic Layout is selected.

      The problem exists for both J2SE 1.4 and 1.5.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      This minimum example displays the problem every time:

      import javax.swing.*;
      import java.awt.event.*;
      import java.awt.GridLayout;
      import java.util.Locale;

      public class TR_RadioButton extends JFrame {
        public TR_RadioButton(String name) {
          super(name);
          ButtonGroup bg = new ButtonGroup();
          JRadioButton radio1 = new JRadioButton("Test 1");
          JRadioButton radio2 = new JRadioButton("Test 2");
          bg.add(radio1);
          bg.add(radio2);
          getContentPane().setLayout(new GridLayout(2, 1));
          getContentPane().add(radio1);
          getContentPane().add(radio2);
          setSize(100, 100);

          addWindowListener(new WindowAdapter() {
              public void windowOpened(WindowEvent evt) {
              }
              public void windowClosing(WindowEvent evt) {
                System.exit(0);
              }
            });
        }

        public static void main(String[] args) {
          // radio buttons rendered correct for US and other locales
      // Locale.setDefault(Locale.US);
          // radio buttons incorrectly rendered for tr_TR (Turkish) locale
          // with Windows XP Layout
          Locale.setDefault(new Locale("tr", "TR"));

          // rendering is only incorrect for WindowsLookAndFeel so it the
          // below lines are commented out rendering is OK
          try {
            UIManager.setLookAndFeel(new com.sun.java.swing.plaf.windows.WindowsLookAndFeel());
          }
          catch (Exception e) {
            e.printStackTrace();
          }

          JFrame f = new TR_RadioButton("Invisible radio buttons");
          f.setVisible(true);
        }
      }

      Steps to reproduce:
      1. Compile the above example on J2SE 1.4 or 1.5
      2. Make sure that Windows XP Layout has been selected in Windows setting for the desk top/screen
      3. Run the example with the command "java -cp . TR_RadioButton"
      4. A JFrame is display with two radio buttons but without rendering of the check box parts.
      5. While the JFrame is displayed change to Windows Classic Layout in the Windows setting for the desk top/screen. Notice that radio buttons now display as expected.

      6. Now select Windows XP Layout again. Edit the example program setting the default locale to Locale.US. Recompilne and run. Verify that radio buttons are now rendered as expected.
      7. Last edit the example program again. Set default locale to tr_TR again and comment out selection of Windows look and feel. Recompile and run. Verify that radio buttons for this combination is also rendered as expected.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      JRadioButton should render with correct chech boxes on Windows XP look and feel for all combinations of locales, including the turkish tr_TR locale. Makes it kind of hard for turkish speaking users to see the current selection for a JRadioButton.
      ACTUAL -
      With a combination of tr_TR locale on Windows XP look and feel the current selection of a group of JRadioButtons can not be determined.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      - Compile with "javac TR_RadioButton.java"
      - Run with "java -cp . TR_RadioButton"

      import javax.swing.*;
      import java.awt.event.*;
      import java.awt.GridLayout;
      import java.util.Locale;

      public class TR_RadioButton extends JFrame {
        public TR_RadioButton(String name) {
          super(name);
          ButtonGroup bg = new ButtonGroup();
          JRadioButton radio1 = new JRadioButton("Test 1");
          JRadioButton radio2 = new JRadioButton("Test 2");
          bg.add(radio1);
          bg.add(radio2);
          getContentPane().setLayout(new GridLayout(2, 1));
          getContentPane().add(radio1);
          getContentPane().add(radio2);
          setSize(100, 100);

          addWindowListener(new WindowAdapter() {
              public void windowOpened(WindowEvent evt) {
              }
              public void windowClosing(WindowEvent evt) {
                System.exit(0);
              }
            });
        }

        public static void main(String[] args) {
          // radio buttons rendered correct for US and other locales
      // Locale.setDefault(Locale.US);
          // radio buttons incorrectly rendered for tr_TR (Turkish) locale
          Locale.setDefault(new Locale("tr", "TR"));

          // rendering is only incorrect for WindowsLookAndFeel
          // rendering is correct for other look and feels
          try {
            UIManager.setLookAndFeel(new com.sun.java.swing.plaf.windows.WindowsLookAndFeel());
          }
          catch (Exception e) {
            e.printStackTrace();
          }

          JFrame f = new TR_RadioButton("Invisible radio buttons");
          f.setVisible(true);
        }
      }

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

      CUSTOMER SUBMITTED WORKAROUND :
      none found (other than selecting to run Windows XP using the classic layout).
      ###@###.### 2005-03-15 12:15:38 GMT

      ----------------------------------

      Additional information: Most Swing components fail to render correctly in the
      Turkish or Azeri locales. This problem does not only apply to JComboBox.
      ###@###.### 2005-06-07 06:32:10 GMT

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              leifs Leif Samuelsson (Inactive)
              Reporter:
              ndcosta Nelson Dcosta (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: