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

JTable rendering not bidi compliant

    XMLWordPrintable

    Details

      Description

      FULL PRODUCT VERSION :
      mustang, b53

      ADDITIONAL OS VERSION INFORMATION :
      irrelevant

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      irrelevant

      A DESCRIPTION OF THE PROBLEM :
      JTable rendering is not BIDI compliant

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      - compile and run the example
      - look at the cell alignment: the left table is LToR (western) component orientation, the right table is RToL (eastern) Co - the right table should be a mirror of the left.

      same with editors (no code shown, but you probably get the drift)

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      see above
      ACTUAL -
      see above

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package swing;


      import java.awt.BorderLayout;
      import java.awt.ComponentOrientation;

      import javax.swing.JFrame;
      import javax.swing.JScrollPane;
      import javax.swing.JTable;
      import javax.swing.table.DefaultTableModel;

      /**
       * @author Jeanette Winzenburg
       */
      public class DefaultTableRendererBidiBug {

          public DefaultTableRendererBidiBug() {

          DefaultTableModel dtm = new DefaultTableModel(0, 2) {
              public Class getColumnClass(int column) {
                  if (column == 0) {
                      return Integer.class;
                  }
                  return super.getColumnClass(column);
              }
          };
          dtm.addRow(new Object[] {10, "firstRow"});
          dtm.addRow(new Object[] {20, "secondRow" });
          final JTable lToRTable = new JTable();
          lToRTable.setModel(dtm);
          JScrollPane lToRPane = new JScrollPane(lToRTable);
          lToRPane.applyComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
          final JTable rToLTable = new JTable();
          rToLTable.setModel(dtm);
          JScrollPane rToLPane = new JScrollPane(rToLTable);
          rToLPane.applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);

          JFrame frame = new JFrame("LToR <--> RToL");
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.getContentPane().setLayout(new BorderLayout());
          frame.getContentPane().add(lToRPane, BorderLayout.WEST);
          frame.getContentPane().add(rToLPane, BorderLayout.EAST);
          frame.pack();
          frame.setVisible(true);

        }

        public static void main(String[] args) {
          new DefaultTableRendererBidiBug();
        }

      }


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

      CUSTOMER SUBMITTED WORKAROUND :
      see

      https://swingx.dev.java.net/issues/show_bug.cgi?id=145

      for comments on the current swing state and how SwingLabs-Swingx works around them (shouldn't need to)

        Attachments

          Activity

            People

            Assignee:
            peterz Peter Zhelezniakov
            Reporter:
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Imported:
              Indexed: