JDK-6466675 : api/java_awt/ScrollPane/descriptions.html#sets doesn't work correctly on windows.
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 6
  • Priority: P2
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows
  • CPU: generic
  • Submitted: 2006-09-01
  • Updated: 2012-03-22
  • Resolved: 2006-09-06
Related Reports
Duplicate :  
Relates :  
Description
JCK            : JCK6.0 b29
J2SE           : FAIL - mustang b97
Platform[s]    : FAIL - windows
switch/Mode    : FAIL - default

It seems that consequent calls of setScrollPosition stops working properly after some time. Two JCK tests fail because of this: 

api/java_awt/ScrollPane/descriptions.html#sets[ScrollPane0408_15]
api/java_awt/ScrollPane/descriptions.html#sets[ScrollPane0415_15]

Steps to reproduce:

run the following code on windows.

import java.awt.*;
import java.io.PrintWriter;
import java.util.Properties;
import java.util.Vector;

public class ScrollPaneTest{

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

        for (int i = 0; i < 10; i++) {
            try 
	    {
		        p = new Point(55, 55);
	                sp.setScrollPosition(p.x, p.y);
                	waitForScrollPosition(sp, p);

		        p = new Point(56, 56);
	                sp.setScrollPosition(p.x, p.y);
                	waitForScrollPosition(sp, p);

            } 
	    catch (InterruptedException e) 
	    {
                	frame.dispose();
                	System.out.println( "couldn't wait till the right scroll position" );
			return;
            }
        }
        frame.dispose();
        System.out.println("OKAY");
 }


    public static void waitForScrollPosition(ScrollPane sp,Point p)
        throws InterruptedException {

        String lock = "the lock";
        synchronized (lock) {
	    System.out.println("ScrollPositio is: "+sp.getScrollPosition()+" should be "+p);
            for (int i=0; !p.equals(sp.getScrollPosition()) && (i < 10); i++) {
			System.out.println("ScrollPosition is: "+sp.getScrollPosition()+" should be "+p);
                lock.wait(1000);
            }
            if ( !p.equals(sp.getScrollPosition()) ) {
                System.out.println("set position: "+p);
                System.out.println("get position: "+sp.getScrollPosition());
                throw new InterruptedException("Bad scroll position for pretty long time");
            }
        }
    }




}


You'll see that despite this code just moves scroll position from 55,55 to 56,56 and backwards it works for the first time but after some attempts goes to 0,56.

Comments
EVALUATION That seems to be a duplicate of 6404832, so it is fixed in jdk7 by now (fix goes to the projected b02). The wrong behavior is reproducible (as it is with 6404832) in XP, XP theme (not Classic) and Vista. Let's discuss if it is a showstopper for jdk6. Evaluating 6404832, I decided singlehandedly it was too risky for Mustang. Perhaps we should let the jdk7 to be tested for some time with this fix, and then backport it to an update release.
04-09-2006