1

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?

distractedhamster
  • 689
  • 2
  • 8
  • 22
Rush
  • 19
  • 1
  • 3
  • 3
    Click 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

0 Answers0