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

JSlider does not display the correct value of its BoundedRangeModel

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 7
    • 6u10
    • client-libs
    • b86
    • x86
    • solaris_2.5.1

      FULL PRODUCT VERSION :
      java version "1.6.0_13"
      Java(TM) SE Runtime Environment (build 1.6.0_13-b03)
      Java HotSpot(TM) Client VM (build 11.3-b02, mixed mode, sharing)


      ADDITIONAL OS VERSION INFORMATION :
      Linux version 2.6.28-11-generic (buildd@palmer) (gcc version 4.3.3 (Ubuntu 4.3.3-5ubuntu4) ) #42-Ubuntu SMP Fri Apr 17 01:57:59 UTC 2009

      A DESCRIPTION OF THE PROBLEM :
      If a JSlider has a BoundedRangeModel that overrides setValue so that it may or may not set the value to the value passed in to the setValue method then the JSlider shows the value passed into the setValue method and not the value actually stored in the model as decided by the setValue method.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Override BoundedRangeModel setValue method and do nothing inside it. Connect a JSlider to this model.

      For example:

      new JSlider(new DefaultBoundedRangeModel()
      {
         public void setValue(int value)
         {
            // Do nothing
         }
      });

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The slider knob should not be able to be moved because the model's value cannot be changed if using the above code.
      ACTUAL -
      The slider knob moves as if the value in the model is actually changed. If another slider is connected to the same model then the second slider does not move and the 2 sliders can show different values even though they are connected to the same model.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package test;

      import javax.swing.DefaultBoundedRangeModel;
      import javax.swing.JFrame;
      import javax.swing.JSlider;

      public class Main
      {
          public static void main(String[] args)
          {
              final JFrame frame = new JFrame();

              final DefaultBoundedRangeModel sliderModel = new DefaultBoundedRangeModel()
              {
                  @Override
                  public void setValue(int n)
                  {
                      // Don't allow value to be changed.
                  }
              };

              frame.getContentPane().add(new JSlider(sliderModel));
              frame.pack();
              frame.setVisible(true);
          }
      }

      ---------- END SOURCE ----------

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: