Solved

simulating the JavaScript mouse over function in Java

Posted on 1997-05-17
2
527 Views
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
application?

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
0
Comment
Question by:kkranz
[X]
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
2 Comments
 
LVL 6

Accepted Solution

by:
jpk041897 earned 50 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
application?

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:

http://www.phrantic.com/scoop/Java000.htm


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

http://www.inf.uni-hohenheim.de/top/java/tutorial/ui/drawing/usingImages.htm
l

for information (and samples) regarding images.

0
 

Author Comment

by:kkranz
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.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

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