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

JSlider(BoundedRangeModel) constructor adds two ChangeListeners to model.

XMLWordPrintable

      FULL PRODUCT VERSION :
      java version "1.5.0"


      ADDITIONAL OS VERSION INFORMATION :
      Linux 2.6.21.4-ibmrt1.24 x86_64

      A DESCRIPTION OF THE PROBLEM :
      The JSlider(BoundedRangeModel) constructor adds two ChangeListeners to model. One is added in the setModel() method, the other is added in the constructor.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Invoke JSlider(BoundedRangeModel brm). Note that two ChangeListeners for the JSlider are added to the BoundedRangeModel.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Expected a single ChangeListener for the JSlider to be added to the model.
      ACTUAL -
      Two ChangeListeners were added to the BoundedRangeModel.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      BoundedRangeModel model = new DefaultBoundedRangeModel();
      JSlider slider = new JSlider(model);

      for(ChangeListener listener : model.getChangeListeners) {
          System.out.println(listener.toString());
      }

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

      CUSTOMER SUBMITTED WORKAROUND :
      Create the JSlider first, then call setModel():

      BoundedRangeModel model = new DefaultBoundedRangeModel();
      JSlider slider = new JSlider();
      slider.setModel(model);

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: