This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "add image into buttons etc" Watch "add image into buttons etc" New topic
Author

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
SCWCD 1.4
Formula 1 app by Maxis (Playbook)
Vani Shastri
Ranch Hand

Joined: Aug 17, 2006
Posts: 52
Hi,

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.
 
Don't get me started about those stupid light bulbs.
 
subject: add image into buttons etc
 
Similar Threads
[URGENT]Displaying an Image as an background of a JPanel
an array of buttons in an applet ?
To add outer text in middle of any text area.
image actions
I have question about JFilechooser?