-
Bug
-
Resolution: Fixed
-
P4
-
1.2.0
-
None
-
beta
-
generic
-
solaris_2.6
The JSlider component does not behave properly when the labels (keys) exist
in the labelTable which are less than the current minimum or greater than the
current maximum. These labels are "stacked" at the nearest endpoint of the
slider. Such labels should not be displayed. A simple way to get into this
situation is:
slider = new JSlider(JSlider.HORIZONTAL, 0, 50, 0);
slider.setMajorTickSpacing(10);
slider.setPaintLabels(true);
slider.setMaximum(30);
The call to setPaintLabels(true) causes a labelTable to be built with the
values 0,10,20,30,40,50. The repaint after the call to setMaximum(30) causes
the labels 30,40,50 to be "stacked" on the rightmost tick of the slider.
-----------------------------------------------------------------------
It should be noted, that a similar problem exists when the maximum is
expanded past the maximum at the time when setPaintLabels is called.
No labels exist in the table for these points, so none are rendered.
However, at this time, it would be difficult (impossible?) to tell if
the label table was generated by createStandardLabels() or uniquely
generated by the application. Hence, a new label table should not be
generated. The application can work around this tracking the maximum
value in the label table and calling the the following series of methods
when a new maximum label value is needed:
slider.setLabelTable(slider.createStandardLabels(
slider.getMajorTickSpacing()));
A similar situation exists for mimimum values. Although I think this behavior
is reasonable, it should be documented as part of the interface specification.
(Note, this needs to include the time(s) at which the JSlider class will
initialize a label table. This is more than just at setPaintLabels().
in the labelTable which are less than the current minimum or greater than the
current maximum. These labels are "stacked" at the nearest endpoint of the
slider. Such labels should not be displayed. A simple way to get into this
situation is:
slider = new JSlider(JSlider.HORIZONTAL, 0, 50, 0);
slider.setMajorTickSpacing(10);
slider.setPaintLabels(true);
slider.setMaximum(30);
The call to setPaintLabels(true) causes a labelTable to be built with the
values 0,10,20,30,40,50. The repaint after the call to setMaximum(30) causes
the labels 30,40,50 to be "stacked" on the rightmost tick of the slider.
-----------------------------------------------------------------------
It should be noted, that a similar problem exists when the maximum is
expanded past the maximum at the time when setPaintLabels is called.
No labels exist in the table for these points, so none are rendered.
However, at this time, it would be difficult (impossible?) to tell if
the label table was generated by createStandardLabels() or uniquely
generated by the application. Hence, a new label table should not be
generated. The application can work around this tracking the maximum
value in the label table and calling the the following series of methods
when a new maximum label value is needed:
slider.setLabelTable(slider.createStandardLabels(
slider.getMajorTickSpacing()));
A similar situation exists for mimimum values. Although I think this behavior
is reasonable, it should be documented as part of the interface specification.
(Note, this needs to include the time(s) at which the JSlider class will
initialize a label table. This is more than just at setPaintLabels().