Solved

MouseOver

Posted on 2004-04-28
8
311 Views
Last Modified: 2010-03-31
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
0
Comment
Question by:garth15
  • 6
8 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 10938939
Keep an array of images, change them in the mouse over event, calling repaint
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10938949
It may help if you were to go into more detail of what you want though...
0
 

Author Comment

by:garth15
ID: 10938980
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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
LVL 86

Expert Comment

by:CEHJ
ID: 10939003
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
 
LVL 86

Accepted Solution

by:
CEHJ earned 500 total points
ID: 10939063
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 10939070
(calling repaint at the end, after testing each one)
0
 
LVL 23

Expert Comment

by:rama_krishna580
ID: 10939509
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10939838
8-)
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question