0

I have made ​​a third thumb -yellow one- for this java swing range slider. If I move first and second thumb I see the change of values in jlabels during movement to the left or right. But the third thumb (it has yellow color and from me) send to jLabel2 only the last value, it does not show the changes in the value during the movement to the right or left. How can solve this problem ,so that I see the changing values during movements ?

My GitHub Link :

https://github.com/zeydbilal/RangeSliderWithThreeThumbs/blob/master/src/rangeSliderWithThreeThumbs/RangeSliderWithThreeThumbs.java

Code from my test file :

rangeSliderWithThreeThumbs1.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                rangeSliderWithThreeThumbs1StateChanged(evt);
            }
        });

private void 
rangeSliderWithThreeThumbs1StateChanged(javax.swing.event.ChangeEvent evt) {                                                         
//value from fist thumb 
   jLabel1.setText(Integer.toString(rangeSliderWithThreeThumbs1.getValue()));
//value from second thumb 
   jLabel3.setText(Integer.toString(rangeSliderWithThreeThumbs1.getUpperValue()));
//value from third thumb  
  jLabel2.setText(Integer.toString(rangeSliderWithThreeThumbs1.getSecondUpperValue()));
    } 

enter image description here

Z.B
  • 61
  • 8
  • My first guess would be that when the rightmost thumb is moved, you simply forget to call the ChangeListener. Check the logic associated with moving the thumb – Gumbo Dec 30 '15 at 20:49
  • Actually in the mouseDragged method I call moveSecondUpperThumb() and there is everything OK. I see there the change of values. – Z.B Dec 30 '15 at 22:06
  • I have changed addChangeListener with addMouseMotionListener. It works! – Z.B Jan 07 '16 at 23:50
  • addMouseMotionListener(new MouseMotionAdapter() {mouseDragged() {/*my code*/}}); – Z.B Jan 07 '16 at 23:58

0 Answers0