2

When implementing JSlider's ChangeListener, the event is fired whenever the value changes. I need to get the last value of a JSLider: I don't need every value visited by the slider, just the last value when the user releases the slider pointer.

firas
  • 1,463
  • 4
  • 19
  • 42
  • Do you have any existing code which we could see? – Matt Asbury Jan 20 '11 at 20:16
  • There is no logic specific behavior. The code just implements the Change listener and prints the value, when the app run, I get all visited values on the std out. – firas Jan 20 '11 at 20:22

1 Answers1

3

Check getValueIsAdjusting() inside stateChanged function.

  JSlider source = (JSlider)e.getSource();
  if (!source.getValueIsAdjusting()) {
       ....
  }
vinga
  • 1,912
  • 20
  • 33