Given the following code:
import javafx.beans.property.{BooleanProperty, SimpleBooleanProperty}
import javafx.beans.value.{ChangeListener, ObservableValue}
val booleanProperty: BooleanProperty = new SimpleBooleanProperty()
booleanProperty.addListener((_, _, newValue) => {})
booleanProperty.addListener(new ValueChangeListener)
final class ValueChangeListener extends ChangeListener[Boolean] {
def changed(observable: ObservableValue[_ <: Boolean], oldValue: Boolean, newValue: Boolean): Unit = ???
}
In IntelliJ this leads to the following compiler error:
overloaded method addListener with alternatives: (x$1: javafx.beans.value.ChangeListener[_ >: java.lang.Boolean])Unit <and> (x$1: javafx.beans.InvalidationListener)Unit cannot be applied to (com.example.app.ApplicationContext.Preferences.PreferencesValueChangeListener[scala.Boolean]) hidePackageColumnProperty.addListener(new PreferencesValueChangeListener(hidePackageColumnSpec))
But why? The first addListener
works fine, the second does not.