// Adding listener to activateProperty.
getSkinnable().activeProperty().addListener(new InvalidationListener() {
@Override
public void invalidated(Observable arg0) {
final Magnifier skinnable = getSkinnable();
if (skinnable.isActive()) {
skinnable.addEventFilter(MouseEvent.MOUSE_ENTERED, enteredEvent);
skinnable.addEventFilter(MouseEvent.MOUSE_EXITED, exitedEvent);
skinnable.addEventFilter(MouseEvent.MOUSE_MOVED, movedEvent);
if (!getChildren().contains(mask)) {
getChildren().add(mask);
}
} else {
skinnable.removeEventFilter(MouseEvent.MOUSE_ENTERED, enteredEvent);
skinnable.removeEventFilter(MouseEvent.MOUSE_EXITED, exitedEvent);
skinnable.removeEventFilter(MouseEvent.MOUSE_MOVED, movedEvent);
if (getChildren().contains(mask)) {
getChildren().remove(mask);
}
}
}
});
if (getSkinnable().isActive()) {
final Magnifier skinnable = getSkinnable();
skinnable.addEventFilter(MouseEvent.MOUSE_ENTERED, enteredEvent);
skinnable.addEventFilter(MouseEvent.MOUSE_EXITED, exitedEvent);
skinnable.addEventFilter(MouseEvent.MOUSE_MOVED, movedEvent);
}
// Adding listener to contentProperty.
getSkinnable().contentProperty().addListener(new InvalidationListener() {
@Override