JButton getColor?

Hi,

I want to write some code that will change the color of a button with a mouseEntered.  I can change the color ok but I want it to return to it's original color on the mouseExited event.

I thought I could create a new variable using

Color orig;

orig = b1.getColor     (b1 being the name of one of my button variables)

Unfortunately this doesn't work. How can I save the original color of the button so I can revert back to it on mouseExited?

tia Flo
LVL 1
flo_the_lil_minxAsked:
Who is Participating?
 
objectsCommented:
> Color orig;

that should work, just make sure orig is a member var
0
 
flo_the_lil_minxAuthor Commented:
I'm sorry, I don't understand?
0
 
objectsCommented:
orig needs to be a member var (and not a local var)
0
 
flo_the_lil_minxAuthor Commented:
I got it

I should've used

orig = b1.getBackground();

instead of

orig = b1.getColor();

Thanks for your help
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.