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

Inconsistency between JLabel and JTextField when ComponentOrientation set to RTL

    XMLWordPrintable

    Details

      Description

      FULL PRODUCT VERSION :
      java version "1.8.0_25"
      Java(TM) SE Runtime Environment (build 1.8.0_25-b18)
      Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.3.9600]

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Windows 8.1 64bit
      NVIDIA GeForce 850M
      If any help: in windows Region dialog, Home Location is set to United States, Current language for non-Unicode programs is set to English (United States).

      A DESCRIPTION OF THE PROBLEM :
      I have a strange problem regarding Right-To-Left component orientation in swing.
      There is an inconsistency between JLabel and JTextField regarding the display of the same string containing hebrew, english and digit characters.
      The two components do not render the text the same.

      Please note the following link to Stack Overflow:
      http://stackoverflow.com/questions/27542648/inconsistency-between-jlabel-and-jtextfield-when-componentorientation-set-to-rtl

      This contains also the screenshots.




      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Just run the attached SSCCE.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The same string should be rendered the same on both components.
      There is no screenshot since I do not know of any workaround.
      BTW - if I remove the setting of the ComponentOrientation, then, obviously, the string is rendered the same on both components.
      ACTUAL -
      The same string is rendered differently on the two components.
      Take a look at the following screenshot:
      http://i.imgur.com/KrVjMLw.png

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.BorderLayout;
      import java.awt.Color;
      import java.awt.ComponentOrientation;

      import javax.swing.JFrame;
      import javax.swing.JLabel;
      import javax.swing.JPanel;
      import javax.swing.JTextField;
      import javax.swing.SwingUtilities;
      import javax.swing.border.EmptyBorder;
      import javax.swing.border.LineBorder;

      public class GuiTest2 extends JFrame
      {
          public GuiTest2()
          {
              super( "Test" );

              JLabel testLabel = new JLabel();
              testLabel.setComponentOrientation( ComponentOrientation.RIGHT_TO_LEFT );
              testLabel.setText( "ca 12 בדיקה" );
              testLabel.setBorder( new LineBorder( Color.BLACK ) );

              JTextField testTextField = new JTextField();
              testTextField.setComponentOrientation( ComponentOrientation.RIGHT_TO_LEFT );
              testTextField.setText( "ca 12 בדיקה" );
              testTextField.setBorder( new LineBorder( Color.BLACK ) );

              JPanel panel = new JPanel( new BorderLayout( 5, 5) );
              panel.setBorder( new EmptyBorder( 10, 10, 10, 10 ) );
              panel.add( testLabel, BorderLayout.NORTH );
              panel.add( testTextField, BorderLayout.SOUTH );

              setContentPane( panel );
              pack();
              setLocationRelativeTo( null );
              setVisible( true );
          }

          public static void main( String[] args )
          {
              SwingUtilities.invokeLater( new Runnable()
              {
                  @Override
                  public void run()
                  {
                      new GuiTest2();
                  }
              } );
          }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      There is no workaround

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              trebari Tejpal Rebari
              Reporter:
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: