[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now


simulating the JavaScript mouse over function in Java

Posted on 1997-05-17
Medium Priority
Last Modified: 2011-10-03
I'm trying to write a standalone java application (not an applet).  I'm
using Symantec's Visual Cafe Pro (if that's important).

One of the functions I need to implement is the Java Script mouse over.
I have a single large gif.  Within the gif are 4 areas that, when the
mouse moves over, I'd like to replace with a highlight image.

Example: picture a large gif of an airplane.  As I move the mouse over
the windows, I'd like to have people's faces pop-up.

My questions are:

1) is it better to split the base image into smaller images (ie the
plane and each separate window) or to have one big initial gif?

2) is there a mouse over function or do I have to trap mouse position?

3) is there a way to support Java Script directly in a standalone java

If you don't mind, could you please CC me via e-mail on any response.
Thanks in advance.

PS: I'm never too proud to accept example source code ;)

Ken Kranz                        WEB Systems Administrator
mailto:http://kkranz@ebbtide.com      V: 516.582.5270 x333
Question by:kkranz
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

jpk041897 earned 100 total points
ID: 1220542
>1) is it better to split the base image into smaller images (ie the
>plane and each separate window) or to have one big initial gif?

No, keep the image straight.

>2) is there a mouse over function or do I have to trap mouse >position?

Yes, its the handleEvent() method. Its general form is:

/*File Event01.txt
This is Listing 19-12 from Using Java, Special Edition
by Joseph Weber, et al.
public boolean handleEvent(Event evt) {
  switch (evt.id) {
    case Event.MOUSE_ENTER: return mouseEnter(evt, evt.x, evt.y);
    case Event.MOUSE_EXIT: return mouseExit(evt, evt.x, evt.y);
    case Event.MOUSE_MOVE: return mouseMove(evt, evt.x, evt.y);
    case Event.MOUSE_DOWN: return mouseDown(evt, evt.x, evt.y);
    case Event.MOUSE_DRAG: return mouseDrag(evt, evt.x, evt.y);
    case Event.MOUSE_UP: return mouseUp(evt, evt.x, evt.y);
    case Event.KEY_PRESS:
    case Event.KEY_ACTION: return keyDown(evt, evt.key);
    case Event.KEY_RELEASE:
    case Event.KEY_ACTION_RELEASE: return keyUp(evt, evt.key);

    case Event.ACTION_EVENT: return action(evt, evt.arg);
    case Event.GOT_FOCUS: return gotFocus(evt, evt.arg);
    case Event.LOST_FOCUS: return lostFocus(evt, evt.arg);
  } //end switch
  return false;

>3) is there a way to support Java Script directly in a standalone >java

No, Javascript is completley browser dependant.

>PS: I'm never too proud to accept example source code ;)

Although I don't know of any examples that specificaly adrees your request,
the theory and samples in the first three lessons at:


should be enough to get you going. You might also want to look at:


for information (and samples) regarding images.


Author Comment

ID: 1220543
The MOUSE_ENTER & MOUSE_EXIT were the keys that I was looking for.  I ended up overlaying an image viewer on each hot area.  Using MOUSE_ENTER & MOUSE_EXIT I can make the java script hot cursor look alike.  In fact, by using the image viewer I can now circulate between various images as the cursor goes over the same area.

Good answer though.  Thanks so much for the help.

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses

649 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