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

JScrollPane does not layout properly with RTL (RIGHT_TO_LEFT)

    XMLWordPrintable

Details

    Description

      Name: jk109818 Date: 04/09/2003


      FULL PRODUCT VERSION :
      java version "1.4.1_01"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01)
      Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode)

      FULL OS VERSION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      RTL alignment, components inside of a JScrollPane's viewport are not laid out properly. Even if the components are supposed to fill horizontally the viewport, RTL layout does not do that. The components are pushed to the right of the scrollpane using their minimum size.
      If the component orientation is LTF in the test case, the components are properly laid out.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      See the test case. Mainly set the component orientation to RTL. When using JScrollPane, the viewport's view is not laid out properly.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      The component inside of the JScrollPane's viewport should be laid out the same way than LTR.
      The components are laid out to the right side of the scollpane but does not take expand to the left.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      // JDK
      import java.awt.BorderLayout;
      import java.awt.ComponentOrientation;
      import java.awt.GridBagConstraints;
      import java.awt.GridBagLayout;
      import java.awt.Insets;
      import javax.swing.JFrame;
      import javax.swing.JPanel;
      import javax.swing.JScrollPane;
      import javax.swing.JTextField;
      import javax.swing.JTree;

      /**
       * This tests the problem with RTL alignment and JScrollPane.
       */
      public class RTLScollPaneTest
      {
      public static void main(String[] args)
      {
      // Create the frame
      JFrame frame = new JFrame();
      frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
      frame.setLocation(100, 100);
      frame.setTitle("RTL alignment vs JScrollPane");
      frame.setSize(400, 500);

      GridBagConstraints constraints = new GridBagConstraints();
      JPanel subComponent = new JPanel(new GridBagLayout());

      // Add the scroll pane and let it use all the space in the frame
      JScrollPane scrollPane = new JScrollPane(subComponent);
      frame.getContentPane().add(scrollPane, BorderLayout.CENTER);

      // Add a text field
      JTextField textField = new JTextField("This is a text field.");

      constraints.gridx = 0;
      constraints.gridy = 0;
      constraints.gridwidth = 1;
      constraints.gridheight = 1;
      constraints.weightx = 1;
      constraints.weighty = 0;
      constraints.fill = GridBagConstraints.HORIZONTAL;
      constraints.anchor = GridBagConstraints.LINE_START;
      constraints.insets = new Insets(10, 10, 0, 10);

      subComponent.add(textField, constraints);

      // Add a tree
      JTree tree = new JTree();

      constraints.gridx = 0;
      constraints.gridy = 1;
      constraints.gridwidth = 1;
      constraints.gridheight = 1;
      constraints.weightx = 1;
      constraints.weighty = 1;
      constraints.fill = GridBagConstraints.BOTH;
      constraints.anchor = GridBagConstraints.CENTER;
      constraints.insets = new Insets(10, 10, 10, 10);

      subComponent.add(new JScrollPane(tree), constraints);

      // Set the layout to be RTL
      frame.applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);

      frame.setVisible(true);
      }
      }

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

      CUSTOMER SUBMITTED WORKAROUND :
      None so far
      (Review ID: 183731)
      ======================================================================
      ###@###.### 10/13/04 18:48 GMT

      Attachments

        Activity

          People

            Unassigned Unassigned
            jkimsunw Jeffrey Kim (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: