JAVA JButton not transparent when clciked Weird ????

Hi i'm coding a smaal java app, adn my problem is i have a JFrame to that i had a JPanel and to that a JButton with a ImageIcon

All is well and it display the button with the transparent image but when i click it it ( when the mouse is down on the button it turns into gray  ??\how do i fix this ?
thank you

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You should set the icons for the various button states if necessary. See the following methods of AbstractButton (the superclass)

 void setDisabledIcon(Icon disabledIcon)
 void setDisabledSelectedIcon(Icon disabledSelectedIcon)
 void setIcon(Icon defaultIcon)
 void setPressedIcon(Icon pressedIcon)
 void setRolloverIcon(Icon rolloverIcon)
 void setSelectedIcon(Icon selectedIcon)
jacquesdrAuthor Commented:
but it's the who;e button i don't think it has todo with the icon when i press the button it's gray when i releases it it fine again

small test app
public class t extends JFrame
 private Color purple                = new Color(100,102,156);
 JLabel l = new JLabel("22.gif");
 JButton b = new JButton("www," ,new ImageIcon("22.gif"));





      setVisible( true);

public static void main(String[] args)
       new t ();

You should maybe set the pressed icon. Can you post that gif somewhere public?
HTML5 and CSS3 Fundamentals

Build a website from the ground up by first learning the fundamentals of HTML5 and CSS3, the two popular programming languages used to present content online. HTML deals with fonts, colors, graphics, and hyperlinks, while CSS describes how HTML elements are to be displayed.

jacquesdrAuthor Commented:
Well i set the pressed Icon property - no diffrence
the gif is transparent the gif is not the problem !

Yes, i understand what you mean now. The default behaviour of a button is to turn down when pressed and is indeed nothing to do with the icon. What do you want to happen?
jacquesdrAuthor Commented:
Sorry man was at work ;)
Well i want it to be still purple(transparent) i'll just maby then need to use labels instead ???

Mick BarryJava DeveloperCommented:

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jacquesdrAuthor Commented:
Thank you very much !!!
it's great ! ;)
Mick BarryJava DeveloperCommented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.