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

JScrollPane does not add H scrollbar when adding V Scrollbar

XMLWordPrintable

    • kestrel
    • generic, x86, sparc
    • generic, solaris_7, windows_nt



      Name: diC59631 Date: 07/29/98


      Here is some simple code to display a JTree in a JScrollPane. If you resize the window vertically small enough to require a vertical
      scrollbar you will see that it doesn't add a horizontal scrollbar even though some of the viewport is obscured by the vertical
       scrollbar.

      But to be honest what it should really have done is added the width of the scrollbar to the preferred size of the viewport in
       determining the preferred size of the scrollpane. In other words it should have made the scrollpane's preferred size wider. This
      is probably very difficult to handle in practice because the preferred size would be dependent on whether the scroll bar is being
       shown which is dependent on the size which is affected by the preferred size.

      --------------------
      import com.sun.java.swing.event.*;
      import java.awt.*;

      public class test extends JFrame implements ScrollPaneConstants
      {
          private test() throws Exception
          {
              JScrollPane scrollPane = new JScrollPane( new JTree(),
                                                    VERTICAL_SCROLLBAR_AS_NEEDED,
                                                    HORIZONTAL_SCROLLBAR_AS_NEEDED );

              getContentPane().add( scrollPane, BorderLayout.EAST );

              setSize( 640, 400 );
          }

          public static void main( String[] args ) throws Exception
          {
              new test().show();
          }
      }
      (Review ID: 35971)
      ======================================================================

      Name: skT88420 Date: 05/21/99


      When the sum of the minimum size of columns in a JTable
      with autoresizing enabled exceed the size of the
      viewport (the JTable is contained by a JScrollPane)
      a horizonal scrollbar should be added to the JScrollPane.
      (Review ID: 57899)
      ======================================================================

            svioletsunw Scott Violet (Inactive)
            dindrigo Daniel Indrigo (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: