Resolved: How do I show the bottom background to the buttons?

In this post, we will see how to resolve How do I show the bottom background to the buttons?

Question:

I have two classes, one where I create the frame and all the other things, and the class “RoundedButton”, that is extended to JButton, where I modify the buttons in order to make it Rounded. When I run the programme and hover the mouse over the button the bottom background disappears. This is the class RoundedBotton:
This is the method, where I create the frame and all other stuff:
I expect to hover themouse over the buttons and still see the colour of the panel where it is posizionated

Best Answer:

So, on MacOS, you’re “roll over” workflow doesn’t work for me AND, it also paints the focus rectangle, which isn’t pretty…
enter image description here
So, instead of doing this…
I would instead make use of the “roll over” support which already exists and change your class to something more like…
enter image description here
Oh, and calling setPreferredSize is a really bad idea

If you have better answer, please add a comment about this, thank you!

Source: Stackoverflow.com