문제

How can I programmatically fire the change listener of a JSlider?

도움이 되었습니까?

해결책

Assuming you want to notify listeners of the slider, you would use this:

    ChangeEvent ce = new ChangeEvent(slider);
    for(ChangeListener cl : slider.getChangeListeners()){
        cl.stateChanged(ce);
    }

You shouldn't need to fire the change event directly unless you're extending the class and adding some new funky functionality. In that case, the fireStateChanged() method is protected, so you should have access.

다른 팁

slider.setValue(value) will fire a state changed event.

have look at ChangeListener, examples here and here

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top