*
The moose likes Swing / AWT / SWT and the fly likes Adding Image to a button Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Adding Image to a button" Watch "Adding Image to a button" New topic
Author

Adding Image to a button

chander shivdasani
Ranch Hand

Joined: Oct 09, 2007
Posts: 206

I want to add an Image to a button once a button is pressed. To do that, i am using the following code:



The Problem is, whenever i am using setPressedIcon it does not display the image, but when i replace it by setIcon, it works.But i have to diable the button once it is pressed, so i do setEnabled(false), which changes the color of the image

How do i do this?


Enjoy, Chander
SCJP 5, Oracle Certified PL/SQL Developer
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10175
    
    8

Check out AbstractButton#setDisabledIcon()


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
Please read this link:

BeForthrightWhenCrossPostingToOtherSites
 
jQuery in Action, 2nd edition
 
subject: Adding Image to a button
 
Similar Threads
How to get image (icon) from a JButton
How to make a proper button listener?
Why can't my button's Image Icon change when i set Icon???
Disabling Submit Button
submit button problem in IE