-
Bug
-
Resolution: Duplicate
-
P4
-
6u1
-
x86
-
windows_xp
Keyboard controls work partially or do not work at all if JSlider.setSnapToTicks() was invoked and minor ticks value is different from "1".
For example, if major ticks value is 6 and minor ticks value is 2 the knob can be moved only to the right (but not to the left) using the keyboard. Setting minor ticks value to 3 makes knob moveable only by mouse drag (mouse clicks do not work either).
(reproduced with 1.4.2_04-b05, 1.5.0_06-b05, 1.6.0-rc-b96)
Please compile and run following code to reproduce the problem:
----------------- ATest.java ----------------------
import javax.swing.*;
public class ATest {
public void sliderTest() {
JFrame f = new JFrame();
JSlider slider = new JSlider(JSlider.HORIZONTAL, 0, 50, 25);
slider.setMinimum(0);
slider.setValue(0);
slider.setMaximum(30);
slider.setPaintLabels(true);
slider.setPaintTicks(true);
slider.setMinorTickSpacing(2);
slider.setMajorTickSpacing(6);
slider.setSnapToTicks(true);
JPanel panel = new JPanel();
panel.add(slider);
panel.setVisible(true);
f.getContentPane().add(panel);
f.pack();
f.setVisible(true);
}
public ATest() {
}
public static void main(String argv[]) {
ATest t = new ATest();
t.sliderTest();
}
}
-------------------------------------------------------
For example, if major ticks value is 6 and minor ticks value is 2 the knob can be moved only to the right (but not to the left) using the keyboard. Setting minor ticks value to 3 makes knob moveable only by mouse drag (mouse clicks do not work either).
(reproduced with 1.4.2_04-b05, 1.5.0_06-b05, 1.6.0-rc-b96)
Please compile and run following code to reproduce the problem:
----------------- ATest.java ----------------------
import javax.swing.*;
public class ATest {
public void sliderTest() {
JFrame f = new JFrame();
JSlider slider = new JSlider(JSlider.HORIZONTAL, 0, 50, 25);
slider.setMinimum(0);
slider.setValue(0);
slider.setMaximum(30);
slider.setPaintLabels(true);
slider.setPaintTicks(true);
slider.setMinorTickSpacing(2);
slider.setMajorTickSpacing(6);
slider.setSnapToTicks(true);
JPanel panel = new JPanel();
panel.add(slider);
panel.setVisible(true);
f.getContentPane().add(panel);
f.pack();
f.setVisible(true);
}
public ATest() {
}
public static void main(String argv[]) {
ATest t = new ATest();
t.sliderTest();
}
}
-------------------------------------------------------
- duplicates
-
JDK-6524424 JSlider Clicking In Tracks Behavior Inconsistent For Different Tick Spacings
-
- Closed
-