Skip to content

Instantly share code, notes, and snippets.

@dhust
Created March 3, 2016 14:39
Show Gist options
  • Save dhust/c6347487fe0c5b5cd5a6 to your computer and use it in GitHub Desktop.
Save dhust/c6347487fe0c5b5cd5a6 to your computer and use it in GitHub Desktop.
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() + ")");
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment