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

Scrollbar layout strangeness with RTL

    XMLWordPrintable

    Details

      Description

      JScrollPane seems a little confused about the placement of the horizontal scrollbar in RIGHT_TO_LEFT orientation, moving it depending on the height of the window.

      Steps to reproduce:
      1) Run the included test case. A frame appears, containing a JTextArea in a JScrollPane.
      2) Grab the bottom edge of the frame in the middle, and drag upward, making the frame shorter. Soon, the vertical scrollbar will appear. Notice that the horizontal scrollbar becomes shorter, and the empty box appears in the corner between the scrollbars.
      3) Resize the window to make the vertical scrollbar disappear.
      4) Select Orientation->Right-To-Left from the menu to change
      5) Again, shrink the window to make the vertical scrollbar appear.
      6) Here's the bug: initially, the corner box appears on the right hand side of the scrollpane. This is incorrect. If you keep shrinking the window, the horizontal scrollbar shifts over to be in the correct position. Obviously, this behavior is not correct.

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

      public class RTLScrollpane extends JFrame implements ActionListener {
          JCheckBoxMenuItem rightToLeft;

          public RTLScrollpane() {
              super("RTLScrollpane");
              JTextArea jta = new JTextArea();
              for (int i = 0; i < 6; i++) {
                  jta.append("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n");
              }
              JScrollPane jsp = new JScrollPane(jta);
              getContentPane().add(jsp);
              setSize(200, 200);

              rightToLeft = new JCheckBoxMenuItem("Right-To-Left", false);
              rightToLeft.addActionListener(this);
              JMenuBar jmb = new JMenuBar();
              setJMenuBar(jmb);
              JMenu menu = new JMenu("Orientation");
              menu.add(rightToLeft);
              jmb.add(menu);
          }

          public void actionPerformed(ActionEvent e) {
              if (e.getSource() == rightToLeft) {
                  if (rightToLeft.getState()) {
                      applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
                      invalidate();
                      validate();
                  }
                  else {
                      applyComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
                      invalidate();
                      validate();
                  }
              }
          }

          public static void main(String[] args) {
              RTLScrollpane f = new RTLScrollpane();
              f.setVisible(true);
          }
      }

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            bchristi Brent Christian
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Imported:
              Indexed: