Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+19 votes

I changed the appearance of some buttons in scene builder, but I don't know how to get them to change their appearance when hovered (like inverting the colors when the mouse is over the button to show that it's clickable). The default buttons have a hover effect, and I thought I would just be able to edit it in scene builder, but I can't find any section for doing that.

Is there a way to edit the hover style effects in Scene Builder?
And if I needed to change the hover effect manually in the code, how would I do that?

asked in CSC305 Fall 2022 by (1 point)

3 Answers

+11 votes

I'm not an expert in this area, but this StackOverflow answer sounds informed...

https://stackoverflow.com/questions/50885101/javafx-inline-css-hover-effect

(Side note: I am encouraging teams to focus on functionality first, prioritizing it over aesthetic concerns.)

answered by (3.5k points)
+9 votes

You can use a CSS style sheet to do it. Just give your button a class and use that class to add a hover declaration in which you can give it the properties you want.

answered by (1 point)
+8 votes

You can also add this line of code and edit the color RGB code for the button and hover color as you wish,

myButton.setStyle("-fx-normal-background: #000000; -fx-hovered-background: #FFFFFF;");

answered by (1 point)
...