3

I want to do a JButton with PNG icon but the clickable area have to be a pixel and not a transparency pixel, and position this JButton over other JButtons like position absolute in css.

thanks in advance

mre
  • 43,520
  • 33
  • 120
  • 170
Jean Michael
  • 117
  • 1
  • 2
  • 7

1 Answers1

2

Create a JLabel with the imge and add a MouseListener. In the listener check Point of the MouseEvent. Get pixel from the image for the point and check alpha of the image's point color. If it's not transparent do your action.

StanislavL
  • 56,971
  • 9
  • 68
  • 98