JDK-4549183 : JTable cell's display order is changed after double clicking
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2001-12-06
  • Updated: 2003-06-18
  • Resolved: 2003-06-18
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
Bidi text is first displayed correctly upon executing JTable application. 
After double clicking a cell containing bidi text, its display order is changed.
For example,
  THE YEAR 1958 HHHHHHH (H means hebrew.)
is changed to
  HHHHHHH THE YEAR 1958
when the text in the cell is chosen by double clicking.

To reproduce this bug:

1- Compile and run the following code
2- Note that Bidi text is displayed correctly
3- DoubleClick one of the bottom-left cells, which contains bidi text. 
4- Note that the text's display order is changed.
5- Click on any other cell
6- Note that Bidi text is displayed correctly again in the previously opened cell

Testing environment:  Hebrew Win2000, Multilingual Win2000, Japanese Sol8


----------Code------------
/* Copyright (c) Sun Microsystems 1998

$Header: /home/sun/src/JDK1.2/jTable.java,v 1.11 2000/03/30 08:13:08 isam Exp $

*/

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

public class jTable extends JApplet
{
        public void init()
        {
                SimpleTable st = new SimpleTable();
                getContentPane().add(st);
        }


        public static void main(String[] argv)
        {
                JFrame frame = new JFrame("\u0645\u062b\u0627\u0644");
                frame.setContentPane(new SimpleTable());
                frame.pack();
                frame.setVisible(true);
        frame.addWindowListener( new WindowAdapter()
        {
             public void windowClosing( WindowEvent e)
             {
                 System.exit(0);
             }
        });

        }
}


class SimpleTable extends JPanel
{

        public SimpleTable()
        {

                JTable jt = new JTable(new String[][]
                {
                {"\u05d6\u05d5\u0020\u05e9\u05e0\u05d4\u0020\u05d9\u05e4\u05d4",
                "\u0647\u0630\u0627\u0020\u064a\u0648\u0645\u0020\u0644\u0637\u064a\u0641\u0020\u05d6\u05d4\u0020\u05d9\u05d5\u05dd\u0020\u05e0\u05e2\u05d9\u05dd",
                "\u062a\u0641\u0627\u062d\u0020\u0623\u062d\u0645\u0631\u0020\u0643\u0628\u064a\u0631\u0020\u0042\u0049\u0047\u0020\u0052\u0045\u0044\u0020\u0041\u0050\u0050\u004c\u0045\u0053",
                "\u006c\u0069\u006d\u0065\u0020\u0069\u0073\u0020\u0067\u0072\u0065\u0065\u006e\u05d7\u05d5\u05de\u05d5\u05e1\u0020\u05d9\u05e7\u05e8"},
                {"\u006c\u0069\u006d\u0065\u0020\u05d7\u05d5\u05de\u05d5\u05e1\u0020\u05d9\u05e7\u05e8\u0069\u0073\u0020\u0067\u0072\u0065\u0065\u006e",
                "\u05d7\u05d5\u05de\u05d5\u05e1\u0020\u006c\u0069\u006d\u0065\u0020\u0069\u0073\u0020\u0067\u0072\u0065\u0065\u006e\u0020\u05d9\u05e7\u05e8","\u006c\u0069\u006d\u0065\u0020\u05d7\u05d5\u05de\u05d5\u05e1\u0020\u05d9\u05e7\u05e8\u0069\u0073\u0020\u0067\u0072\u0065\u0065\u006e"},
                {"\u05d6\u05d5\u0020\u05e9\u05e0\u05d4\u0020\u05d9\u05e4\u05d4\u0020\u0054\u0048\u0045\u0020\u0059\u0045\u0041\u0052\u0020\u0031\u0039\u0035\u0038",
               "\u05d7\u05d5\u05de\u05d5\u05e1\u0020\u006c\u0069\u006d\u0065\u0020\u0069\u0073\u0020\u0067\u0072\u0065\u0065\u006e\u0020\u05d9\u05e7\u05e8" ,"\u05d6\u05d5\u0020\u05e9\u05e0\u05d4\u0020\u05d9\u05e4\u05d4\u0020\u0054\u0048\u0045\u0020\u0059\u0045\u0041\u0052\u0020\u0031\u0039\u0035\u0038"}},
               new String[] {"\u062a\u0641\u0627\u062d\u0020\u0623\u062d\u0645\u0631\u0020\u0643\u0628\u064a\u0631\u0020\u0042\u0049\u0047\u0020\u0052\u0045\u0044\u0020\u0041\u0050\u0050\u004c\u0045\u0053",
               "\u0647\u0630\u0627\u0020\u064a\u0648\u0645\u0020\u0644\u0637\u064a\u0641\u0020\u05d6\u05d4\u0020\u05d9\u05d5\u05dd\u0020\u05e0\u05e2\u05d9\u05dd"});
    JScrollPane jsp = new JScrollPane(jt);
    jt.setFont(new Font("Lucida Sans Regular",Font.PLAIN,15));
    add(jsp, BorderLayout.CENTER);

        }
}

--------------------------

Comments
EVALUATION The reason of this problem is that the logic to decide the default run direction of BIDI embedded string is different between Swing text components and other Swing components, i.e., the default run direction follows the component orientation in Swing text components, while the Unicode BIDI algorithm is applied inside Graphics2D.drawString() in the other Swing components. This is the same issue discussed in 4701238, so I will close this as a duplicate. ###@###.### 2003-06-17
17-06-2003