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

ScrollPane.setScrollPosition() does not always set position correctly

XMLWordPrintable

    • sparc
    • solaris_2.5



      Name: vsC58871 Date: 01/23/98



      ScrollPane's methods setScrollPosition(int,int) and ScrollPosition(Point)
      don't set position of scrollbars correctly.

      Here is the example demonstrating the bug:

      ----------------Test.java---------------------
      import java.awt.*;

      public class Test {
          public static void main(String [] args) {
              Point p;
      Frame frame = new Frame();
      frame.setBounds(100,100,100,100);
      ScrollPane sp = new ScrollPane(ScrollPane.SCROLLBARS_AS_NEEDED);
      Canvas canvas = new Canvas();
      canvas.setSize(300,300);
      sp.add(canvas);
      frame.add("Center",sp);
      frame.setVisible(true);

      for (int i=0;i<1000;i++) {
      p = new Point(i%100,i%100);
      sp.setScrollPosition(p);
      if (!sp.getScrollPosition().equals(p)) {
      System.out.println("Test Failed.");
      System.out.println(i+" : Expected "+p+", but Returned: "+sp.getScrollPosition());
      frame.dispose();
      System.exit(0);
                  }
              }
      System.out.println("Test Passed.");
      frame.dispose();
          }
      }

      -- The output ----------------
      #>java Test
      Test Failed.
      15 : Expected java.awt.Point[x=15,y=15], but Returned: java.awt.Point[x=12,y=15
      ------------------------------

      ======================================================================

            Unassigned Unassigned
            vsizikov Vladimir Sizikov
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: