The reason this method works is that you already added a listener to the slider that says "whenever the slider's value changes, update the frame being shown". Calling slider.setValue(...) will change the value (just as if the user had dragged the slider with the mouse), and will trigger the same event.