File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

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: 10824

Check out AbstractButton#setDisabledIcon()

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

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

I agree. Here's the link:
subject: Adding Image to a button
It's not a secret anymore!