String is wrongly getting flipped even when using lro character in jdk 1.6

XMLWordPrintable

    • Type: Bug
    • Resolution: Not an Issue
    • Priority: P4
    • None
    • Affects Version/s: 1.4.0, 6
    • Component/s: client-libs
    • 2d
    • generic, x86
    • generic, windows_xp

      FULL PRODUCT VERSION :
      java version "1.6.0_03"
      Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
      Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      If we use LRO character in the string, the string should not be flipped and
      it should appear from left to right as it is. But this behaviour is broken in
      1.5 and 1.6 for strings having spaces. In 1.3, if I use LRO character in the
      string "‭שמשח " and set it for JTextArea, it
      appears as "‭שמשח ". The string text used is
      "\u202D\u05E9\u05DE\u05E9\u05D7\u0020\u0020\u0020\u0020". But the same string
      appears as " ‭שמשח" in 1.6. Testcase below

      import java.awt.ComponentOrientation;
      import java.awt.event.WindowAdapter;
      import java.awt.event.WindowEvent;

      import javax.swing.JFrame;
      import javax.swing.JPanel;
      import javax.swing.JTextArea;


      public class JTextDemo extends JPanel
      {
        public JTextDemo()
        {
          JTextArea text2 = new JTextArea(20, 20);
          String string1 =
      "\u202D\u05E9\u05DE\u05E9\u05D7\u0020\u0020\u0020\u0020";
          text2.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
          text2.setText(string1);
          add(text2);
        }
       
        public static void main(String args[])
        {
          JFrame fr = new JFrame("JTextDemo");
          fr.getContentPane().add(new JTextDemo());
          fr.addWindowListener(new WindowAdapter()
          {
            public void windowClosing(WindowEvent we)
            {
              System.exit(0);
            }
          });
          fr.pack();
          fr.setVisible(true);
        }
      }

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the testcase pasted above in JDK 1.6.0 and observe the string

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The string should appear as "‭שמשח "
      ACTUAL -
      But the string appears as " ‭שמשח"

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.ComponentOrientation;
      import java.awt.event.WindowAdapter;
      import java.awt.event.WindowEvent;

      import javax.swing.JFrame;
      import javax.swing.JPanel;
      import javax.swing.JTextArea;


      public class JTextDemo extends JPanel
      {
        public JTextDemo()
        {
          JTextArea text2 = new JTextArea(20, 20);
          String string1 =
      "\u202D\u05E9\u05DE\u05E9\u05D7\u0020\u0020\u0020\u0020";
          text2.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
          text2.setText(string1);
          add(text2);
        }
       
        public static void main(String args[])
        {
          JFrame fr = new JFrame("JTextDemo");
          fr.getContentPane().add(new JTextDemo());
          fr.addWindowListener(new WindowAdapter()
          {
            public void windowClosing(WindowEvent we)
            {
              System.exit(0);
            }
          });
          fr.pack();
          fr.setVisible(true);
        }
      }
      ---------- END SOURCE ----------

            Assignee:
            Steven Loomis
            Reporter:
            Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: