wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes add image into buttons etc Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "add image into buttons etc" Watch "add image into buttons etc" New topic

add image into buttons etc

Nicky Eng
Ranch Hand

Joined: Mar 26, 2005
Posts: 378
I have buttons,

example i got "Open" button, but i also want to put the image into the button.

which method to do so?

From NickyEng
Diploma in Computer Studies
SCJP 1.4
Formula 1 app by Maxis (Playbook)
Vani Shastri
Ranch Hand

Joined: Aug 17, 2006
Posts: 52

jbtnPic1 = new JButton();
jbtnPic1.setIcon(new ImageIcon ("C:/images/open.gif"));

guess this should work.
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
or use the constructor

public JButton(Icon icon)
Nicky Eng
Ranch Hand

Joined: Mar 26, 2005
Posts: 378
thank you all seniors.
Consider Paul's rocket mass heater.
subject: add image into buttons etc
Similar Threads
[URGENT]Displaying an Image as an background of a JPanel
To add outer text in middle of any text area.
an array of buttons in an applet ?
image actions
I have question about JFilechooser?