I created a JButton in java and I set a png logo icon to it. The icon is round with transparent background and I want that the button is activated only when I click on the image and not on the transparent background. How can I do it?
Asked
Active
Viewed 60 times
1
-
3Click detection is based on the contains(...) method. You need to override the `contains(...)` method to return the size of the oval representing your icon. See: https://stackoverflow.com/questions/24028358/change-jbutton-focus-area/24028405#24028405 for a basic example. – camickr Mar 28 '21 at 17:10