Solved

simulating the JavaScript mouse over function in Java

Posted on 1997-05-17
2
461 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
2 Comments
 
LVL 6

Accepted Solution

by:
jpk041897 earned 50 total points
Comment Utility
>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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This video teaches viewers about errors in exception handling.

771 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

11 Experts available now in Live!

Get 1:1 Help Now