I have the following method
private void initializeMoveOnClick(final Group window){
window.addEventFilter(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent mouseEvent) {
//do some stuff
}
});
}
How do I go about replacing the overrided handle method declaration with a lambda expression?
You have mostly two ways to do it:
private void initializeMoveOnClick(final Group window){
window.addEventFilter(MouseEvent.MOUSE_CLICKED, e -> runSomeMethod());
}
and:
private void initializeMoveOnClick(final Group window){
window.addEventFilter(MouseEvent.MOUSE_CLICKED, this::eventFilter);
}
private void eventFilter(MouseEvent e) {
//do some stuff
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With