-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
5.0
-
x86
-
windows_xp
FULL PRODUCT VERSION :
java version "1.5.0_03"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_03-b07)
Java HotSpot(TM) Client VM (build 1.5.0_03-b07, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
The maximum value attributed to a JScrollBar is reduced by 10, regardless of maximum declared.
The issue being that if the submitted max<10 the JScrollBar is initialised by roll-over, (the BoundedRangeModel rules apply), effecting the entire model...
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1) Create a JScrollBar using the default constructor.
2) set the maximum and current values < 10.
4) Observe the extents and values reported by getXXX()
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
A JScrollBar accurately reporting its underlying extents and current value.
ACTUAL -
The model/scrollbar appears to be reducing the provided MAXIMUM value by 10.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.GridLayout;
import java.awt.event.AdjustmentEvent;
import java.awt.event.AdjustmentListener;
import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollBar;
public class ScrollBug {
public static void main(String[] vals)
{
final JScrollBar bar_small = new JScrollBar(JScrollBar.HORIZONTAL);
bar_small.setName("small");
bar_small.setMinimum(0);
bar_small.setMaximum(9);
bar_small.setValue(5);
final JScrollBar bar_large = new JScrollBar(JScrollBar.HORIZONTAL);
bar_large.setName("large");
bar_large.setMinimum(0);
bar_large.setMaximum(1000);
bar_large.setValue(40);
final JLabel label_small = new JLabel(""+bar_small.getValue());
label_small.setBorder(BorderFactory.createEtchedBorder());
final JLabel label_large = new JLabel(""+bar_large.getValue());
label_large.setBorder(BorderFactory.createEtchedBorder());
bar_small.addAdjustmentListener(new AdjustmentListener()
{
public void adjustmentValueChanged(AdjustmentEvent arg0) {
label_small.setText(""+bar_small.getValue());
}
}
);
bar_large.addAdjustmentListener(new AdjustmentListener()
{
public void adjustmentValueChanged(AdjustmentEvent arg0) {
label_large.setText(""+bar_large.getValue());
}
}
);
JFrame frm = new JFrame("BAR TEST");
frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel suite = new JPanel(new GridLayout(2, 2));
suite.add(label_large);
suite.add(label_small);
suite.add(bar_large);
suite.add(bar_small);
frm.add(suite);
frm.pack();
frm.setLocationRelativeTo(null);
frm.setVisible(true);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
subbing the JScrollBar and implementing modifier code in order to catch the <10 issue, as well as correcting the values returned by getXXX()... not ideal.
java version "1.5.0_03"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_03-b07)
Java HotSpot(TM) Client VM (build 1.5.0_03-b07, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
The maximum value attributed to a JScrollBar is reduced by 10, regardless of maximum declared.
The issue being that if the submitted max<10 the JScrollBar is initialised by roll-over, (the BoundedRangeModel rules apply), effecting the entire model...
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1) Create a JScrollBar using the default constructor.
2) set the maximum and current values < 10.
4) Observe the extents and values reported by getXXX()
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
A JScrollBar accurately reporting its underlying extents and current value.
ACTUAL -
The model/scrollbar appears to be reducing the provided MAXIMUM value by 10.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.GridLayout;
import java.awt.event.AdjustmentEvent;
import java.awt.event.AdjustmentListener;
import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollBar;
public class ScrollBug {
public static void main(String[] vals)
{
final JScrollBar bar_small = new JScrollBar(JScrollBar.HORIZONTAL);
bar_small.setName("small");
bar_small.setMinimum(0);
bar_small.setMaximum(9);
bar_small.setValue(5);
final JScrollBar bar_large = new JScrollBar(JScrollBar.HORIZONTAL);
bar_large.setName("large");
bar_large.setMinimum(0);
bar_large.setMaximum(1000);
bar_large.setValue(40);
final JLabel label_small = new JLabel(""+bar_small.getValue());
label_small.setBorder(BorderFactory.createEtchedBorder());
final JLabel label_large = new JLabel(""+bar_large.getValue());
label_large.setBorder(BorderFactory.createEtchedBorder());
bar_small.addAdjustmentListener(new AdjustmentListener()
{
public void adjustmentValueChanged(AdjustmentEvent arg0) {
label_small.setText(""+bar_small.getValue());
}
}
);
bar_large.addAdjustmentListener(new AdjustmentListener()
{
public void adjustmentValueChanged(AdjustmentEvent arg0) {
label_large.setText(""+bar_large.getValue());
}
}
);
JFrame frm = new JFrame("BAR TEST");
frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel suite = new JPanel(new GridLayout(2, 2));
suite.add(label_large);
suite.add(label_small);
suite.add(bar_large);
suite.add(bar_small);
frm.add(suite);
frm.pack();
frm.setLocationRelativeTo(null);
frm.setVisible(true);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
subbing the JScrollBar and implementing modifier code in order to catch the <10 issue, as well as correcting the values returned by getXXX()... not ideal.