United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6542335 different behavior on knob of scroll bar between 1.4.2 and 5.0
JDK-6542335 : different behavior on knob of scroll bar between 1.4.2 and 5.0

Details
Type:
Bug
Submit Date:
2007-04-04
Status:
Closed
Updated Date:
2011-03-07
Project Name:
JDK
Resolved Date:
2011-03-07
Component:
client-libs
OS:
windows_xp
Sub-Component:
javax.swing
CPU:
x86
Priority:
P3
Resolution:
Fixed
Affected Versions:
5.0u12
Fixed Versions:

Related Reports
Backport:
Backport:
Backport:
Backport:
Relates:
Relates:

Sub Tasks

Description
Action for knob in scrol bar in 5.0ux is different from that in 1.4.2_14.

Configuration :
 JRE : 5.0u12-b02fcs
 OS  : WinXP(SP2, Japanese)
 Browser : IE6(SP2, Japanese)

REPRODUCE :
To place the attached files, JScrollBarTest.html, JScrollBarCom.class
and  under the same folder(directory)

---JRE5.0u12-b02---
 1) Open attached JScrollBarTest.html by double-clicking
   You will see 2 scroll bars.
 2) Click the knob on the scroll bar at right side.
   The knob moves to the left most position quickly. 
 3) Click the knob on the scroll bar at left side.
  The knob does not move.

---JRE1.4.2_14---
 1) Open attached JScrollBarTest.html by double-clicking
   You will see 2 scroll bars.
 2) Click the knob on the scroll bar at right side.
    The knob does not move. 
 3) Click the knob on the scroll bar at left side.
    The knob does not move

In the above steps, the action in 2) is different.

                                    

Comments
EVALUATION

Perhaps the submitter could provide source code?
                                     
2007-04-05
SUGGESTED FIX

BasicScrollBarUI.java

        public void propertyChange(PropertyChangeEvent e) {
	    String propertyName = e.getPropertyName();

	    if ("model" == propertyName) {
	        BoundedRangeModel oldModel = (BoundedRangeModel)e.getOldValue();
	        BoundedRangeModel newModel = (BoundedRangeModel)e.getNewValue();
		oldModel.removeChangeListener(modelListener);
		newModel.addChangeListener(modelListener);
+               scrollBarValue = scrollbar.getValue();
                scrollbar.repaint();
		scrollbar.revalidate();
                                     
2007-04-09
EVALUATION

This is a real bug

we have to update BasicScrollBarUI.scrollBarValue value
when the model is changed
                                     
2007-04-09
EVALUATION

Test case:

import java.awt.Dimension;
import java.awt.Label;
import java.awt.event.AdjustmentListener;
import java.awt.event.AdjustmentEvent;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeEvent;
import javax.swing.*;

public class JScrollBarCom extends JPanel {
    JScrollBar m_scrollbar;
    JScrollBar m_scrollbar2;
    Label m_label;
    Label m_label2;

    public JScrollBarCom() {
        
        m_scrollbar = new JScrollBar(0, 0, 1, 0, 1);
        m_scrollbar.setPreferredSize(new Dimension(200, 17));
        m_scrollbar.setMaximum(100);
        m_scrollbar.setMinimum(0);
        m_scrollbar.setVisibleAmount(50);
        m_scrollbar.setValue(50);
        
        m_scrollbar2 = new JScrollBar(0, 0, 1, 0, 1);
        m_scrollbar2.setPreferredSize(new Dimension(200, 17));
        DefaultBoundedRangeModel rangeModel = new DefaultBoundedRangeModel();
        rangeModel.setMaximum(100);
        rangeModel.setMinimum(0);
        rangeModel.setExtent(50);
        rangeModel.setValue(50);
        
        
        m_scrollbar2.setModel(rangeModel);
        m_label = new Label("No use setModel()");
        m_label2 = new Label("Use setModel()");
        add(m_label);
        add(m_scrollbar);
        add(m_label2);
        add(m_scrollbar2);

        JButton test = new JButton("Test");
        test.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                m_scrollbar2.setValueIsAdjusting(true);
            }
        });
        add(test);
    }
    
    public static void main(String[] args) {
        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().add(new JScrollBarCom());
        frame.setSize(200, 200);
        frame.setVisible(true);
    }
}
                                     
2007-04-09



Hardware and Software, Engineered to Work Together