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

JTextField RIGHT_TO_LEFT does not behave as it was in java-1.6

XMLWordPrintable

      FULL PRODUCT VERSION :
      java version "1.8.0_31"
      Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
      Java HotSpot(TM) Client VM (build 25.31-b07, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :

      Microsoft Windows [Version 6.0.6002]

      Microsoft Windows [Version 6.1.7601]


      A DESCRIPTION OF THE PROBLEM :
      When I use a JTextField with ComponentOrientation.RIGHT_TO_LEFT and horizontal-alighment of JTestField.RIGHT, setting a long text with mixed-direction (Hebrew and English) causes characters to overlap each other, resulting an unreadable layout.


      REGRESSION. Last worked in version 6u43

      ADDITIONAL REGRESSION INFORMATION:
      java version "1.6.0_18"
      Java(TM) SE Runtime Environment (build 1.6.0_18-b07)
      Java HotSpot(TM) Client VM (build 16.0-b13, mixed mode, sharing)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the source-code code using java-6 and java-7


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      A field showing the hebrew letters in the beginning (right side) and part of the english text in the left-side, with no overlap
      ACTUAL -
      The english text overlaps the hebrew letters. The result is partly unreadable

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package il.aipm.tools.test;

      import java.awt.BorderLayout;
      import java.awt.ComponentOrientation;
      import java.awt.Font;

      import javax.swing.JFrame;
      import javax.swing.JTextField;

      public class TestComponentOrientation extends JFrame {

         private static final long serialVersionUID = 1L;

         private static TestComponentOrientation t;
         private JTextField f1 = new JTextField(15);
         public TestComponentOrientation() {
            super("test");
            f1.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
            f1.setHorizontalAlignment(JTextField.RIGHT);
            f1.setFont(new Font("Lucida Sans",Font.PLAIN,20));

            String s = new String(new char[]{1488,1489,1490});
            char[] cs = new char[3];
            s += " ";
            s += "aaaaabbbbbcccccdddddeee";
            
            setDefaultCloseOperation(EXIT_ON_CLOSE);
            getContentPane().setLayout(new BorderLayout());
            getContentPane().add(f1,BorderLayout.CENTER);
            f1.setText(s);
            pack();
            setVisible(true);
            f1.setCaretPosition(0);
         }

         public static void main(String[] args) throws InterruptedException {
            t = new TestComponentOrientation();
         }
      }

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

      CUSTOMER SUBMITTED WORKAROUND :
      I could not find any workaround.

            ssadetsky Semyon Sadetsky (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: