JButton, setting the backgound colour when clicked
Hi all,
I would like to change the background colour that is displayed while a JButton is being clicked. I have had a look around and can't find anything that tells me.
I know this is probably a quick one but the help would be much appreciated
Thanks
[277 byte] By [
Zeroblacka] at [2007-11-27 11:34:02]

# 1
Hi,
I found 2 methods,l maybe one of them is what you are looking for...:
http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/AbstractButton.html#setPressedIcon(javax.swing.Icon)
http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/plaf/basic/BasicButtonUI.html#paintButtonPressed(java.awt.Graphics,%20javax.swing.AbstractButton)
-Puce
Pucea at 2007-7-29 16:55:00 >

# 2
Thanks for that but neither are really what I need, even putting an Icon in means that the background colour appears around it.
It must be a default that can be set somewhere, but I dont know where.
# 3
> Thanks for that but neither are really what I need,
> even putting an Icon in means that the background
> colour appears around it.
>
> It must be a default that can be set somewhere, but I
> dont know where.
Not necessarily! It could be handled by the look and feel!
That's why I referenced the BasicButtonUI link.
-Puce
Pucea at 2007-7-29 16:55:00 >

# 4
> It must be a default that can be set somewhere, but I dont know where.
You where given the answer. Look at the source code of the UI.
# 5
Yep, ok I got it, problem sorted. I didn't realise I could do that, I have learned more than I thought I would.
Thanks a lot for the help :)