flo_the_lil_minx
asked on
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
orig needs to be a member var (and not a local var)
ASKER
I got it
I should've used
orig = b1.getBackground();
instead of
orig = b1.getColor();
Thanks for your help
I should've used
orig = b1.getBackground();
instead of
orig = b1.getColor();
Thanks for your help
ASKER