A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
JavaRanch
»
Java Forums
»
Java
»
Swing / AWT / SWT
Author
add image into buttons etc
Nicky Eng
Ranch Hand
Joined: Mar 26, 2005
Posts: 378
posted
Aug 18, 2006 02:57:00
0
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
posted
Aug 18, 2006 03:33:00
0
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
posted
Aug 18, 2006 04:08:00
0
or use the constructor
public
JButton
(Icon icon)
Nicky Eng
Ranch Hand
Joined: Mar 26, 2005
Posts: 378
posted
Aug 19, 2006 03:48:00
0
thank you all seniors.
I agree. Here's the link:
http://jrebel.com/download
subject: add image into buttons etc
Similar Threads
an array of buttons in an applet ?
[URGENT]Displaying an Image as an background of a JPanel
image actions
To add outer text in middle of any text area.
I have question about JFilechooser?
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter