Solved

MouseOver

Posted on 2004-04-28
8
309 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
 
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

705 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now