Links in a applet

G

George Hester

I have an applet which is a cube each face if which is a link. I have a floating <DIV> element which when the mouse is over the applet it pops up showing the text of all the links in the applet. What I would like is when the mouse is over one of the faces of the cube the corresponding text in my <DIV> will highlight.

So in other words this is sort of like have a link on a page and when the mouse is held over it, some other area of the html page will highlight. If the link itself highligts that is no problem. I would just like some other area of the page to highlight.

Any suggestions on how to do this? Thanks.
 
M

Martin Honnen

George said:
I have an applet which is a cube each face if which is a link. I
have a floating <DIV> element which when the mouse is over the applet
it pops up showing the text of all the links in the applet. What I
would like is when the mouse is over one of the faces of the cube the
corresponding text in my <DIV> will highlight.

So in other words this is sort of like have a link on a page and when
the mouse is held over it, some other area of the html page will
highlight. If the link itself highligts that is no problem. I would
just like some other area of the page to highlight.

If you really have a Java applet and want it to change the style of an
element in the HTML page containing the Java applet then you need to
allow the applet to script with
<applet mayscript
in the HTML code and inside your applet code you need to
import netscape.javascript.*;
and you can then instantiate the JavaScript window object from Java as
follows
JSObject window = JSObject.getWindow(this);
The window object has then methods outlined at
http://devedge.netscape.com/library/manuals/2000/javascript/1.5/reference/lcjsobj.html
for instance a call method so that you could call a function in the page
window.call("highlightLinkText", new Object[] {"textId"});
Then in the HTML page write a JavaScript function
function highlightLinkText (elementId) {
var element;
if (document.getElementById) {
element = document.getElementById(elementId);
if (element && element.style) {
element.style.backgroundColor = 'lightblue';
}
}
}
and set up the text for each link to have an id e.g.
<p id="link1Text">...</p>

The whole process of Java->JavaScript communication is called
LiveConnect and is not supported by all browsers on all platforms as it
depends on the Java VM supporting it.
 
G

George Hester

Thanks Martin. Yes I saw that at Sun. Unfortunately I cannot change the applet it was purchased. Let me ask this then.

The only change that the Window recognizes when the mouse is held over one of the faces is a change in the Status bar. It reads all I want. The <DIV> element is actually just a rehash of the status bar but all the faces "names" appear at once rather then each seperate face in the Status bar when the mouse is over a face.

So what I did is try to Read the status bar in JavaScript code. That didn't work. For each time I got the Status bar window.status was empty.

So if I could just figure out what if anything changes in the DOM and hopefully has the information of the intended direction of the link. If there is no other way then redesigning the applet, OK that's fine. What I have will be good enough I guess. I'm giving data binding a shot but haven't worked out how to use that yet.

Oh and thanks for your example. I am sure I'll be able to use tht in some other project.

--
George Hester
__________________________________
Martin Honnen said:
George said:
I have an applet which is a cube each face if which is a link. I
have a floating <DIV> element which when the mouse is over the applet
it pops up showing the text of all the links in the applet. What I
would like is when the mouse is over one of the faces of the cube the
corresponding text in my <DIV> will highlight.

So in other words this is sort of like have a link on a page and when
the mouse is held over it, some other area of the html page will
highlight. If the link itself highligts that is no problem. I would
just like some other area of the page to highlight.

If you really have a Java applet and want it to change the style of an
element in the HTML page containing the Java applet then you need to
allow the applet to script with
<applet mayscript
in the HTML code and inside your applet code you need to
import netscape.javascript.*;
and you can then instantiate the JavaScript window object from Java as
follows
JSObject window = JSObject.getWindow(this);
The window object has then methods outlined at
http://devedge.netscape.com/library/manuals/2000/javascript/1.5/reference/lcjsobj.html
for instance a call method so that you could call a function in the page
window.call("highlightLinkText", new Object[] {"textId"});
Then in the HTML page write a JavaScript function
function highlightLinkText (elementId) {
var element;
if (document.getElementById) {
element = document.getElementById(elementId);
if (element && element.style) {
element.style.backgroundColor = 'lightblue';
}
}
}
and set up the text for each link to have an id e.g.
<p id="link1Text">...</p>

The whole process of Java->JavaScript communication is called
LiveConnect and is not supported by all browsers on all platforms as it
depends on the Java VM supporting it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top