aspose file tools*
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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.
I agree. Here's the link:
subject: add image into buttons etc
Similar Threads
image actions
[URGENT]Displaying an Image as an background of a JPanel
To add outer text in middle of any text area.
I have question about JFilechooser?
an array of buttons in an applet ?