JDK-8194733 : JTextField with wrong text render on RIGHT_TO_LEFT component orientation
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 8,9,10
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • OS: windows_7
  • CPU: x86_64
  • Submitted: 2018-01-07
  • Updated: 2021-12-20
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.
Other
tbdUnresolved
Description
FULL PRODUCT VERSION :
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b18)
Java HotSpot(TM) Client VM (build 25.25-b02, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]

EXTRA RELEVANT SYSTEM CONFIGURATION :
Architecture: x86_64; features: SSE2 SSE3 SSSE3 SSE4.1

GPU:
         Card name: NVIDIA Quadro NVS 160M
       Driver Name: nvd3dum.dll
    Driver Version: 9.18.13.3165
         Vendor ID: 0x10DE
         Device ID: 0x06EB
         SubSys ID: 0x02331028
       Revision ID: 0x00A1

A DESCRIPTION OF THE PROBLEM :
when JTextField is filled with text that contains:

right to left text like Arabic, Latin numbers and Latin text

then it only renders right if the complete text Fits inside the JTextField.

text we use to reproduce is:
صندوق ۴۰×۳۰ پایه دار وایرنگ میتر تک فاز

other info: above text is just name of product inside an accounting software we created but our users have match more render failures as we could reproduce.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
create simple app with JTextField
with RIGHT_TO_LEFT component orientation
and set text:
صندوق ۴۰×۳۰ پایه دار وایرنگ میتر تک فاز
then run app and resize until text does not fit


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
fatal JTextField text render
ACTUAL -
JTextField renders text parts at unexpected locations

ERROR MESSAGES/STACK TRACES THAT OCCUR :
there is no error output the problem is just visual

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
//
//like you see below code shows simple JTextField but
//  once you resize the window smaller then the text Fits 
//  you experience dancing numbers
//  but try to select part of text that is more fatal
//
//other info: below text is just name of an product added inside an accounting software
//  we created but our users have match more render failures as we could reproduce.
//
package test;

import java.awt.ComponentOrientation;

public class JavaBug extends javax.swing.JFrame {

    public static void main(String[] args) {
        JavaBug frame = new JavaBug();
        frame.show();
    }
    
    public JavaBug() {
        javax.swing.JTextField textField = new javax.swing.JTextField();
        
        textField.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
        textField.setText("\u0635\u0646\u062F\u0648\u0642 \u06F4\u06F0×\u06F3\u06F0 \u067E\u0627\u06CC\u0647 \u062F\u0627\u0631 \u0648\u0627\u06CC\u0631\u0646\u06AF \u0645\u06CC\u062A\u0631 \u062A\u06A9 \u0641\u0627\u0632");
        textField.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
        
        getContentPane().add(textField);
        pack();
        this.setLocationRelativeTo(null); //enusre get showed at screen center
        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    }
}

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

CUSTOMER SUBMITTED WORKAROUND :
still searching for


Comments
Although I'm not able to reproduce the character overriding part, the RIGHT_TO_LEFT orientation doesnot seem to behave properly.
11-01-2018

Reported with: JDK 8u25 Windows 7 JTextField with right to left text (Arabic, Latin) renders right if the complete text fits inside the JTextField. Checked this with: JDK 8/8u152 Windows 10 The text renders right and override when resized. See attached images as reference. Results: ========= 8: FAIL 8u152: FAIL 9: FAIL 10 ea b37: FAIL To verify, run the attached test case with respective JDK versions.
08-01-2018