File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes JButton with a round image Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JButton with a round image" Watch "JButton with a round image" New topic

JButton with a round image

Alexandre Baldo
Ranch Hand

Joined: Aug 04, 2006
Posts: 48
Hello guys!
I'll try to explain the problem...
I have a JButton:

The ImageIcon is a GIF. A round GIF.
The problema is that when the button is displayed the addButton's border appears as well (there's a rect surrounding it)... I want just the Image to be shown!

Does anyone knows how can I do that?


SCWCD 1.4<br>
SCJP 1.4
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302

Try addButton.setBorderPainted(false)

GenRocket - Experts at Building Test Data
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10836

On XP LAF setBorderPainted(false) might not be sufficient. You might have to use addButton.setBorder(null)

[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46431
Worth doing a search of this forum; questions about round buttons come up about twice a year. If you find anything useful, be sure to post a link to it with the URL button below.
Alexandre Baldo
Ranch Hand

Joined: Aug 04, 2006
Posts: 48
Thank`s guys!
I agree. Here's the link:
subject: JButton with a round image
It's not a secret anymore!