By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,600 Members | 1,861 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,600 IT Pros & Developers. It's quick & easy.

Links in a applet

P: n/a
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.

--
George Hester
__________________________________

Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a


George Hester wrote:
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/...e/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.
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2

P: n/a
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" <ma*******@yahoo.de> wrote in message news:3f********@olaf.komtel.net...


George Hester wrote:
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/...e/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.


--

Martin Honnen
http://JavaScript.FAQTs.com/


Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.