How to give a button a custom shape in Java Swing?

Viewed 107

I'm new to Java Swing, I searched a lot about this question on stackoverflow.com and other websites, but couldn't find a concrete answer, so I decided to ask it myself. I want to create a JButton of a custom shape - of the map of the USA. I have a png image with a transparent background. I know that

    usaButton.setOpaque(false);
    usaButton.setContentAreaFilled(false);

will get rid of border of the button and remove the background color, but I want it to create a border around the map itself whenever I hover my mouse over it, not a rectangular border around the button. This is the map just for the reference:

https://i.stack.imgur.com/B3nIS.png

0 Answers
Related