JDK-4195694 : Scrollbar.set{Value,Values()} fails to generate an AdjustmentEvent
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.1.7
  • Priority: P2
  • Status: Closed
  • Resolution: Won't Fix
  • OS: solaris_7
  • CPU: sparc
  • Submitted: 1998-12-08
  • Updated: 1999-02-22
  • Resolved: 1999-02-22
Related Reports
Relates :  
Relates :  
Description
Problem
-------

java.awt.Scrollbar.setValue() and java.awt.Scrollbar.setValues() fail to
generate an java.awt.event.AdjustmentEvent.

It is expected that such method calls should propagate a:

	java.awt.event.AdjustmentEvent

Code Example
------------

import java.awt.*;
import java.awt.event.*;

public class ScrollbarTest {
    static boolean flag = true;

    public static void main(String argv[]) {

        final Frame f = new Frame();
        final Panel p = new Panel();
        final Scrollbar s = new Scrollbar(Scrollbar.VERTICAL);
        final Button b1 = new Button("setValues() - plural");
        final Button b2 = new Button("setValue()  - singular");
        final Button b3 = new Button("hide/show");
        final Button b4 = new Button("reset");
        final TextArea ta = new TextArea("Adjustment Events \n",
15,2,TextArea.SCROLLBARS_VERTICAL_ONLY);

        s.addAdjustmentListener(new AdjustmentListener() {public void
adjustmentValueChanged(AdjustmentEvent ae){
                System.out.println(ae);
                ta.append(ae.toString()+"\n");
        }});

	// setValues()
	//
        b1.addActionListener(new ActionListener(){public void
actionPerformed(ActionEvent ae){
                for (int i = 0; i <10; i++)
		    s.setValues(i,i,i,i);
        }});

	// setValue()
	//
        b2.addActionListener(new ActionListener(){public void
actionPerformed(ActionEvent ae){
                    s.setValue(5);  
        }});

        b3.addActionListener(new ActionListener(){public void
actionPerformed(ActionEvent ae){
                s.setVisible(getFlag());
        }});

        b4.addActionListener(new ActionListener(){public void
actionPerformed(ActionEvent ae){
                s.setValues(5,3,1,10);
        }});


        f.setLayout(new BorderLayout());
        p.add(b1);
        p.add(b2);
        p.add(b3);
        p.add(b4);
        f.add(p, BorderLayout.CENTER);
        f.add(s, BorderLayout.EAST);
        f.add(ta, BorderLayout.SOUTH);
        f.setSize(750,400);
        f.setVisible(true);

    }

    static boolean getFlag(){
            flag = !flag;
            return flag;
    }
}



To Reproduce
------------

Install Solaris 7 / SPARC.

Obtain JDK 1.1.7B:

		java -version
		java version "1.1.7B"
	
	Sometimes known as:

		java -fullversion
		java full version "JDK1.1.7U"

	(Why I don't know :-)

	Compile the above code.

		javac ScrollbarTest

	Run:
		java ScrollbarTest


	Observe:
		
		No AdjustmentEvents are observed when programmatically
		setValue()/setValues().

	The failure is also demonstrable using:

		java full version "JDK1.1.6N"

	a previous "reference" JDK.

Comments
WORK AROUND Use the "Production" JDK 1.1.6_04. java full version "Solaris_JDK_1.1.6_04"
11-06-2004

EVALUATION We have no intention of fixing this in our distribution of the JDK. The Solaris production version can continue to patch for this bug if they wish. david.mendenhall@eng 1999-02-22
22-02-1999

SUGGESTED FIX Apply the fix mentioned in bugid: 4048060 --------------- We should leave the code as it is - see comments andy.herrick@East 1999-01-12
12-01-1999