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

Merlin-beta3-b83, RTL text in JTextComponent disappears after Ctrl+Shift+O

    Details

    • Subcomponent:
      2d
    • CPU:
      generic
    • OS:
      windows_nt

      Description



      Name: jbT81659 Date: 10/15/2001

      Description: OS: Windows 2000,
      JDK:jdk1.4.0-beta3-b83 (Merlin-Beta3)
      Test case: jTable.java
       
      Pressing "CRTL+SHIFT+O" on a JTable cell that contains RTL ONLY text causes
      that RTL text to disappear.
      If the JTable cell include RTL text like arabic or hebrew alone without any LTR text,
      then this text dissapears upon opening the cell for editing and pressing "CTRL+SHIFT+O"
      to change the text Component orientation.
      This behavior is verified under windows 2000 but not under Solaris sparc and Redhat Linux.
      If LTR text is added to the RTL text, pressing "CTRL+SHIFT+O" does not cause RTL text
      to disappear.
      To reproduce this problem:

      1- Compile and run the following test case jTable.java
      2- Verify that each cell in the first column (from the left) contain one RTL (arabic) word
      3- Double click on any cell in this column
      4- Verify that the RTL (arabic) word is displayed
      5- Press "CTRL+SHIFT+O"
      6- Verify that the word is not displayed on the right end of cell
      7- Verify that spaces have replaced actual glyphs of the RTL word
      8- Verify that cursor is displayed at the end of these spaces
      9- Press "CTRL+SHIFT+O" again
      10- Verify that the word is displayed
      11- Press "CTRL+SHIFT+O" again
      12- add any LTR character(s) to the cell.
      13- Verify that RTL word is displayed once first LTR char is added
      14- Press "CTRL+SHIFT+O" again
      15- Verify that the RTL word and the LTR char(s) are displayed
       
      ============Code======================

      /*
      $Header: $
      */
      import java.awt.*;
      import javax.swing.*;
      import javax.swing.table.*;
      import javax.swing.border.*;
      import java.util.*;
      import java.awt.event.*;
       
      public class jTable
      {
          TableColumn cColumn, vColumn, nColumn;
          TableModel dataModel;
          JTable tableView;
          JComboBox comboBox;
       
          public jTable()
          {
              JFrame frame = new JFrame("JTable Example");
              frame.addWindowListener(new WindowAdapter()
              {
                   public void windowClosing(WindowEvent e) {System.exit(0);}});
                   final String[] names = { "Header1", "Header2", "Header3", "Header4" };
                   final Object[][] data =
                   {
                          {
                         "\u0645\u062b\u0627\u0644",
                         "\u05e9\u05e0\u05d4\u0020\u05d9\u05e4\u05d4",
                         "\u0069\u0073\u0020\u0067\u0072\u0065\u0065\u006e",
                         new Integer(2), new Boolean(true)
                      },
                          {
                         "\u0645\u062b\u0627\u0644",
                         "\u05d6\u05d5\u0020\u05e9\u05e0\u05d4\u0020\u05d9\u05e4\u05d4",
                         "\u0661\u0669\u0665\u0668\u0020\u0031\u0039\u0035\u0038",
                         new Integer(99),
                         new Boolean(false)
                      },
                          {
                         "\u0645\u062b\u0627\u0644",
                         "\u05d6\u05d5\u0020\u05e9\u05e0\u05d4\u0020\u05d9\u05e4\u05d4",
                         "Green", new Integer(838), new Boolean(false)
                      },

                          {
                         "\u0645\u062b\u0627\u0644",
                         "\u05d6\u05d5\u0020\u05e9\u05e0\u05d4\u0020\u05d9\u05e4\u05d4",
                        "\u0661\u0669\u0665\u0668\u0020\u0031\u0039\u0035\u0038",
                         new Integer(8),
                         new Boolean(true)
                      },
                          {
                         "\u0645\u062b\u0627\u0644",
                         "\u05d6\u05d5\u0020\u05e9\u05e0\u05d4\u0020\u05d9\u05e4\u05d4",
                         "\u0661\u0669\u0665\u0668\u0020\u0031\u0039\u0035\u0038",
                         new Integer(3),
                         new Boolean(false)
                      },
                          {
                         "\u0645\u062b\u0627\u0644",
                         "\u05d6\u05d5\u0020\u05e9\u05e0\u05d4\u0020\u05d9\u05e4\u05d4",
                         "\u0069\u0073\u0020\u0067\u0072\u0065\u0065\u006e",
                         new Integer(21),
                         new Boolean(false)
                      },
       
                          {
                         "\u0645\u062b\u0627\u0644",
                         "\u05d6\u05d5\u0020\u05e9\u05e0\u05d4\u0020\u05d9\u05e4\u05d4",
                         "\u0069\u0073\u0020\u0067\u0072\u0065\u0065\u006e",
                         new Integer(14),
                         new Boolean(false)
                      },
              };
       
              dataModel = new AbstractTableModel()
              {
                  public int getColumnCount()
                  {
                      return names.length;
                  }
                  public int getRowCount()
                  {
                      return data.length;
                  }
                  public Object getValueAt(int row, int col)
                  {
                      return data[row][col];
                  }
       
                  public String getColumnName(int column)
                  {
                      return names[column];
                  }
                  public Class getColumnClass(int c)
                  {
                      return getValueAt(0, c).getClass();
                  }
                  public boolean isCellEditable(int row, int col)
                  {
                      return true;
                  }
                  public void setValueAt(Object aValue, int row, int column)
                  {
                      System.out.println("Setting value to: " + aValue);
                      System.out.println();
                      data[row][column] = aValue;
                  }
               };
       
       
              tableView = new JTable(dataModel);
       
                      tableView.setFont(new Font("Lucida Sans Regular",Font.PLAIN,9));
       
              tableView.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
       
              comboBox = new JComboBox();
              comboBox.setFont( new Font("Lucida Sans Regular", Font.PLAIN, 9));
                  comboBox.addItem("\u062a\u0641\u0627\u062d\u0020\u0623\u062d\u0645\u0631\u0020\u0643\u0628\u064a\u0631");
                  comboBox.addItem("\u062a\u0641\u0627\u062d\u0020\u0623\u062d\u0645\u0631\u0020\u0643\u0628\u064a\u0631");
                  comboBox.addItem("\u062a\u0641\u0627\u062d\u0020\u0623\u062d\u0645\u0631\u0020\u0643\u0628\u064a\u0631");
       
              cColumn = tableView.getColumn("Header3");
              cColumn.setPreferredWidth(200);
              cColumn.setCellEditor(new DefaultCellEditor(comboBox));
              DefaultTableCellRenderer colorColumnRenderer = new DefaultTableCellRenderer();
              colorColumnRenderer.setBackground(Color.pink);
              colorColumnRenderer.setToolTipText("Test");
              cColumn.setCellRenderer(colorColumnRenderer);
       
                  TableCellRenderer headerRenderer = cColumn.getHeaderRenderer();
                  if (headerRenderer instanceof DefaultTableCellRenderer)
                  ((DefaultTableCellRenderer)headerRenderer).setToolTipText("This is a test");
       
              TableColumn vColumn = tableView.getColumn("Header4");
              vColumn.setPreferredWidth(200);
       
              nColumn = tableView.getColumn("Header3");
              DefaultTableCellRenderer numberColumnRenderer = new DefaultTableCellRenderer()
              {
                      public void setValue(Object value)
                  {
                      int cellValue = (value instanceof Number) ? ((Number)value).intValue() : 0;
                      setForeground((cellValue > 30) ? Color.black : Color.red);
                      setText((value == null) ? "" : value.toString());
                  }
              };
              nColumn.setPreferredWidth(200);
       
              JScrollPane scrollpane = new JScrollPane(tableView);
                      scrollpane.setBorder(new BevelBorder(BevelBorder.LOWERED));
              scrollpane.setPreferredSize(new Dimension(700, 400));
              frame.setSize(900, 500);
              frame.getContentPane().add(scrollpane);
              frame.setVisible(true);
          }
       
          public static void main(String[] args)
          {
              new jTable();
          }
      }
       
      =======================================

      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                dougfelt Doug Felt
                Reporter:
                jbenavrasunw Jonathan Benavraham (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: