Click here to Skip to main content
15,905,508 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
wanted my button to change color on mouse enter event how do i do in java
Posted
Comments
Sudhakar Shinde 9-Apr-13 6:35am    
Are you sure you want to do this in java? This type of requirement is usually handled in javascript.
Shrikant Sonone 21-Apr-13 14:13pm    
Java Swing or Java Server Pages ?
please clarify

1 solution

Hey,

As you haven't mentioned what have you coded,

i am telling you the general steps of doing that.

Firstly, You should know about button's setBackground() property where you can pass color code as an argument for setting background-color of button. ex- "setBackground(Color.green)"
You can learn about it Here[^]

Secondly, You have to handle the mouse-enter and mouse-exit events(associated with button) and change the background property of button accordingly(change on enter and restore on exit).
You can learn how to set and handle those events Here[^]

Happy Coding..!
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900