大家好,我是下一个代码:
javafx.scene.control.TextInputControl control
control.focusedProperty().addListener(
{ observableValue, t, t1 ->
//some code
}
)
认为代码就像java 8:
control.focusedProperty().addListener((observableValue,t,t1)->{
//some code
});
但是当我尝试运行groovy时会抛出以下错误:
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]
问题是......如何使用lamda groovy完成下一个代码?
control.focusedProperty().addListener(new ChangeListener<Boolean>() {
@Override
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
}
});
答案 0 :(得分:1)
尝试在关闭定义后添加as ChangeListener
。