Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6463630

JSlider - keyboard controls do not work if setSnapToTicks was invoked

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • 7
    • 6u1
    • client-libs

      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();
          }
      }
      -------------------------------------------------------

            rupashka Pavel Porvatov (Inactive)
            alyamov Andrew Lyamov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: