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

Strange JScrollPane resizing when resizing container

XMLWordPrintable

      Name: rmT116609 Date: 03/20/2003


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

      FULL OPERATING SYSTEM VERSION :
      Microsoft Windows 2000 [Version 5.00.2195]

      A DESCRIPTION OF THE PROBLEM :
      When using JScollPanes within a Layout that respects the
      components preffered height the JScrollPane ends up with
      strange sizes.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Run the code
      2. Observe the bottom component is the scroll bar height
      less than we would like it to be
      3. Increase the window width
      4. Now observe that the top component is the scroll bar
      height taller then it should be
      5. Now resize the window back to where it was originally
      6. Observe the components are different heights than they
      were when the window was originally this size
      7. Resize the window to smaller than it was originally
      8. Now observe both components have the wrong heights

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      Expected the sizes of the components to be relative to the
      sizes of the enclosing container.
      Actual for the same size windows components are at different
      sizes, depending on what sizes the windows were resized from.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.*;
      import javax.swing.*;

      public class ScrollPaneTester {
        public static void main(String args[]) {
          JFrame frame = new JFrame();
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          Container contentPane = frame.getContentPane();
          contentPane.add(new JScrollPane(new JButton("Thin Button")),
      BorderLayout.NORTH);
          contentPane.add(new JScrollPane(new JButton("A very wide Button, with long
      text that may cause horizontal scrollbars to be required")), BorderLayout.SOUTH);
          frame.setSize(400, 400);
          frame.setVisible(true);
        }
      }
      ---------- END SOURCE ----------

      CUSTOMER WORKAROUND :
      Make a subclass of JScrollPane with getPrefferedSize
      returning the correct results.
      (Review ID: 180444)
      ======================================================================

            Unassigned Unassigned
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: