user3643247
user3643247

Reputation: 51

groovy cannot resolve with method invoke

Hello guys I've the next code:

javafx.scene.control.TextInputControl control

control.focusedProperty().addListener(

            { observableValue, t, t1 ->
                //some code
            }
    )

Supossed that the code is like java 8:

control.focusedProperty().addListener((observableValue,t,t1)->{

        //some code

    });

But when I try to run groovy throws the following error:

 ADVERTENCIA: groovy.lang.GroovyRuntimeException: Ambiguous method overloading for    method javafx.scene.Node$FocusedProperty#addListener.
Cannot resolve which method to invoke for [class com.srs.javafx.utils.textfield.ValidationTextField$_setMinLenghtValidation_closure1] due to overlapping prototypes between:
[interface javafx.beans.InvalidationListener]
[interface javafx.beans.value.ChangeListener]

The question is... How I can to do the next code with lamda groovy?

control.focusedProperty().addListener(new ChangeListener<Boolean>() {

        @Override
        public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {

        }
    });

Upvotes: 0

Views: 830

Answers (1)

Robby Cornelissen
Robby Cornelissen

Reputation: 97140

Try adding as ChangeListener after your closure definition.

Upvotes: 1

Related Questions