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

JScrollPane and FlowLayout do not interact properly

    Details

    • Subcomponent:
    • Understanding:
      Fix Understood
    • CPU:
      x86
    • OS:
      windows_xp

      Description

      Name: js151677 Date: 08/04/2004


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

      A DESCRIPTION OF THE PROBLEM :
      If you put a FlowLayout panel into a JScrollPane and disable horizontal scrolling, the panel should flow its components into rows and allow for vertical scrolling.

      Instead, the components are arranged into a single row, and any that don't fit within that row simply do not appear.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile and run the attached test case

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Several rows of buttons should be shown, with vertical scrolling enabled if the layout is too long
      ACTUAL -
      Only a single row of buttons is displayed, with the extras simply missing

      REPRODUCIBILITY :
      This bug can be reproduced always.

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

      public class Test extends JPanel implements Scrollable {
          public static void main(String[] arg) {
              JFrame f = new JFrame();
              JScrollPane sp = new JScrollPane(new Test());
              f.getContentPane().add(sp);
              f.setSize(200, 200);
              f.show();
          }
          
          
          public Test() {
              setLayout(new FlowLayout());
              for (int i = 0; i < 25; i++)
                  add(new JButton(String.valueOf(i)));
          }
          
          
          public Dimension getPreferredScrollableViewportSize() {
              return new Dimension(400, 400);
          }
           

          public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction) {
              return 100;
          }
          
          
          public boolean getScrollableTracksViewportHeight() {
              return false;
          }


          public boolean getScrollableTracksViewportWidth() {
              return true;
          }
          
          
          public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction) {
              return 25;
          }
      }

      ---------- END SOURCE ----------
      (Incident Review ID: 295743)
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                dav Andrei Dmitriev (Inactive)
                Reporter:
                jssunw Jitender S (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Imported:
                  Indexed: