dhust
3/3/2016 - 2:39 PM

Slider - event handling. One way to do it.

Slider - event handling. One way to do it.

public class FXMLDocumentController implements Initializable {
    
    // Needs to have @FXML otherwise you'll get errors and your program will not run 
    @FXML private Slider mySlider;
    
    @Override
    public void initialize(URL url, ResourceBundle rb) {
        
        // You have three different variables available
        // I used newValue which is the sliders value after it is moved
        // You can also use observable and oldValue
        mySlider.valueProperty().addListener((observable, oldValue, newValue) -> {
            System.out.println("Slider Value Changed (newValue: " + newValue.intValue() + ")");
        });
    }  
    
}