Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Custom JButton 1

Status
Not open for further replies.

djabell

Instructor
Apr 9, 2001
44
GB
Anyone know a quick way of removing the default blue button background from a JButton? All I want to show is an image icon without the button outline and I'd rather not override the painting of the button if I can help it.

Any help appreciated!
 
JButton myButton = new JButton(new ImageIcon("my image") );
Border noBorder = new LineBorder(Color.WHITE, 0);
myButton.setBorder(noBorder);


I think that should work.
 
Ah! Easy when you think about it! Thanks. Actually used setBorder(BorderFactory.createEmptyBorder(0,0,0,0)) and setBackground(Color.white) but has the same effect as the solution you gave. Dunno why I didn't think of that myself!!

Thanks for that.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top