I'm working on JavaFX app that uses CSS styles that are included in file. What i want is to change CSS style after an action happens on button and i wrote some code that changes style of Button when i enter/exit it:
public void actionMouseEntered() {
buttonReflex1.getStyleClass().clear();
buttonReflex1.getStyleClass().add("button_reflex_pressed");
}
public void actionMouseExited(){
buttonReflex1.getStyleClass().clear();
buttonReflex1.getStyleClass().add("button_reflex");
}
And here you have my CSS file:
.button_reflex{
-fx-shape: "M 200 *a lot of numbers here* Z";
-fx-background-color: radial-gradient(focus-angle 360deg, focus-distance 0%, center 50% 50%, radius 70%, reflect, lightblue, aqua 30%, blue);
-fx-text-fill: linear-gradient(#e4e000 0%, #ff0000 50%, #e4e000 100%);
}
.button_reflex_pressed{
-fx-shape: "M 200 *a lot of numbers here* Z";
-fx-background-color: radial-gradient(focus-angle 360deg, focus-distance 0%, center 50% 50%, radius 70%, reflect, dodgerblue, deepskyblue 30%, darkblue);
-fx-text-fill: linear-gradient(#e4e000 0%, #ff0000 50%, #e4e000 100%);
}
They differ in a color of buttons.
Code i wrote above WORKS, but i think i didn't write it in a good way. Could you tell me if my method of implementing it is correct, or if it isn't, please tell me how can i do it better, because i don't want to learn bad habits.
:hover?