Solved

simulating the JavaScript mouse over function in Java

Posted on 1997-05-17
2
491 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
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Java Jpanels and Jframe 8 32
configure dependency in POM for new database 3 25
throw exception 21 42
Adding multiple JVM environments to RedHat 6 7 18
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
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 …

806 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