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

JScrollPane does not display correctly elements with RTL (RIGHT_TO_LEFT)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 6
    • client-libs

      FULL PRODUCT VERSION :
      Java(TM) SE Runtime Environment (build 1.6.0_05-b13)

      ADDITIONAL OS VERSION INFORMATION :
      Linux 2.6.23.1-42.fc8 #1

      A DESCRIPTION OF THE PROBLEM :
      I have created a frame. I also have created a panel with GridBagLayout and have added two components (text field and label) to it. That panel I have placed onto JScrollPane and that scroll pane I have added onto my frame. After that, I have set orientation for JScrollPane to ComponentOrientation.RIGHT_TO_LEFT and view of my panel was incorrect.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Create JFrame component with BorderLayout
      2. Create JPanel with GridBagLayout and add to it JTextField and JLabel so that they fill whole width of frame
      3. Create JScrollPane component and add to it the panel created in previous step
      4. Set orientation of scroll pane to RIGHT_TO_LEFT
      5. Add that scroll pane onto frame created on step 1


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      panel with text field and label should be stretched along width of frame
      ACTUAL -
      panel with text field and label fill only some part of that frame (not whole)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
       public class TestScrollPane
      {
      public static void main(String... args)
      {
      JDialog dialog = new JDialog();
      dialog.setTitle("Test JScrollPane");
      dialog.setSize(300, 300);
      dialog.setLocation(400, 250);
      dialog.setLayout(new BorderLayout());

      JPanel panel = new JPanel();
      panel.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
      panel.setLayout(new GridBagLayout());
      panel.setBorder(new LineBorder(Color.RED));

      GridBagConstraints c = new GridBagConstraints();

      c.anchor = GridBagConstraints.LINE_START;
      c.fill = GridBagConstraints.NONE;
      c.gridx = 0;
      c.gridy = 0;
      panel.add(new JLabel("FROM"), c);

      c.anchor = GridBagConstraints.CENTER;
      c.fill = GridBagConstraints.HORIZONTAL;
      c.gridx = 1;
      c.gridy = 0;
      c.weightx = 1;
      panel.add(new JTextField(), c);

      JScrollPane scroll = new JScrollPane(panel);
      scroll.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);

      dialog.add(scroll);
      dialog.setVisible(true);
      }
      }
      ---------- END SOURCE ----------

            Unassigned Unassigned
            dav Andrei Dmitriev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: