hello, I made a little game that is similar to "Where's Waldo?", but it has several different people to find in each level.

Anyway, each person is found by the user when he/she clicks on them. Sometimes the people are hidden in a crowd, or hidden in a bigger image.

I have each of the people drawn onto a JButton, which seems to work for my purposes. But, whenever I have the person drawn onto a JButton, it has a square or a ring of blank non-transparency around the image.

I found the setBounds() method for a JButton, and that seems perfect, but it only lets me set the bounds as different sized rectangles or elipses. I also already tried overriding the paintBorder method, but that only lets me paint the actual border. If there was a way to set the bounds as a polygon or something that was a custom shape, then that would be the answer, but I cannot find a way to do that, and have been looking for a while... any ideas?

4 Years
Discussion Span
Last Post by sciwizeh

It is not easy to change the shape of a button. This thread has an answer that shows how to make a button invisible, as you want the image without the border you probably only need the button.setBorderPainted(false); call

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.