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

Scrollbar class's maximum value is diffenret from set value.

XMLWordPrintable

    • Cause Known
    • x86
    • windows_xp

      FULL PRODUCT VERSION :
      java version "1.4.1_07"

      ADDITIONAL OS VERSION INFORMATION :
      Windows XP

      A DESCRIPTION OF THE PROBLEM :
      I create a Scrollbar object by
      Scrollbar sb = new Scrollbar(Scrollbar.HORIZONTAL, 0, 5, 0, 255);
      But the actual maximum value is not 255, but 250!

      The following are the program.
      /*
       File name: ScrollbarEventsBR.java
       *Function overview:A class to demonstrate what I think bug on Scrollbar class.
       *auther: T.H
       *since: 06/06/12
       *version: 1.0
       */

      import java.applet.Applet;
      import java.awt.Scrollbar;
      import java.awt.TextArea;
      import java.awt.event.AdjustmentListener;
      import java.awt.event.AdjustmentEvent;
      /*
          <applet code="ScrollbarEventsBR" width=400 height=200>
          </applet>
      */
      public class ScrollbarEventsBR extends Applet implements AdjustmentListener{
          TextArea ta;
          Scrollbar sb;

          public void init(){
              sb = new Scrollbar(Scrollbar.HORIZONTAL, 0, 5, 0, 255);
              sb.addAdjustmentListener(this);
              add(sb);
              ta = new TextArea(10, 20);
              add(ta);
          }

          public void adjustmentValueChanged(AdjustmentEvent ae){
              ta.append("Value: " + sb.getValue() + "\n");
          }
      }


      REPRODUCIBILITY :
      This bug can be reproduced always.

      CUSTOMER SUBMITTED WORKAROUND :
      Actual maxmum value of a Scrollbar object seems to be "maximum - visible" on the constructor of
      Scrollbar(int orientation, int value, int visible, int minimum, int maxmum).

            dav Andrei Dmitriev (Inactive)
            dav Andrei Dmitriev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: