Reputation: 1
JavaFX So I have code where if mouse on button when color of label is changing
AeroportT1.hoverProperty().addListener((event)->tAeroportT1.setTextFill(Color.web("#ff0909")));
But I need change color back when mouse not on button.
Upvotes: 0
Views: 74
Reputation: 866
You should use ChangeListener
but not InvalidationListener
for your purpose
AeroportT1.hoverProperty().addListener((observable, oldValue, newValue) ->
AeroportT1.setTextFill(newValue ? Color.RED : Color.BLUE));
Or you can use Bindings
AeroportT1.textFillProperty().bind(Bindings.when(AeroportT1.hoverProperty()).then(Color.RED).otherwise(Color.BLUE));
Upvotes: 4