MouseOver

Hi,

I want to create a mouseOver method that changes an images when the cursor is over an image on my interface.  What is the easiest way to do this?  The images are set at certin co-ordinates.

Thanks in advance

Garth
garth15Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
CEHJConnect With a Mentor Commented:
You can get the Rectangle of each body and in the mouse listener do something like:

if (body1.getRectangle().contains(new Point(mouseEvent.getX(),mouseEvent.getX())) {
      // set paint red
}
else {
      // set paint blue
}      
0
 
CEHJCommented:
Keep an array of images, change them in the mouse over event, calling repaint
0
 
CEHJCommented:
It may help if you were to go into more detail of what you want though...
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
garth15Author Commented:
Well I have a chat interface which has bodies on it.  When a user puts his or her cusor over on of these bodies I want the body colour to change.  When they exit the body then for the body to change back to the colour it started at.  I paint the bodies on the interface when they join the chat room via the paint mehtod which uses double buffering and an update method.
0
 
CEHJCommented:
OK, so it sounds like you need to add the mouse listener to this container, determine which body is at the mouse coordinates, change the Paint color of that body and then call repaint
0
 
CEHJCommented:
(calling repaint at the end, after testing each one)
0
 
CEHJCommented:
8-)
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.