JDK-8133246 : JTextField RIGHT_TO_LEFT does not behave as it was in java-1.6
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 7u85,8u20,9
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_7
  • CPU: x86_64
  • Submitted: 2015-08-05
  • Updated: 2015-09-09
  • Resolved: 2015-09-09
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9Resolved
Related Reports
Duplicate :  
Description
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.


Comments
1. Run the attached test case(TestComponentOrientation.java)in Windows 7. 2. Checked this for JDK 6u18, 6u45, 7u85, 8u51, 8u60 ea b26, and 9 ea b75 6u18: OK 6u45: OK 7u85: FAIL 8u51: FAIL 8u60 ea b26: FAIL 9 ea b75: FAIL 3. Output with JDK 6u45 and 8u51 (see attached screenshots) 4. This issue is reproducible with JDK 7u85, 8u51, 8u60 ea b26 and 9 ea b75. The english text overlaps the hebrew letters, however in 6u18 and 6u45 the output is clear (see attached screen-shots).
10-08-2015