Links in a applet

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • George Hester

    #1

    Links in a applet

    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
    _______________ _______________ ____

  • Martin Honnen

    #2
    Re: Links in a applet



    George Hester wrote:
    [color=blue]
    > 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.[/color]

    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.javasc ript.*;
    and you can then instantiate the JavaScript window object from Java as
    follows
    JSObject window = JSObject.getWin dow(this);
    The window object has then methods outlined at

    for instance a call method so that you could call a function in the page
    window.call("hi ghlightLinkText ", new Object[] {"textId"});
    Then in the HTML page write a JavaScript function
    function highlightLinkTe xt (elementId) {
    var element;
    if (document.getEl ementById) {
    element = document.getEle mentById(elemen tId);
    if (element && element.style) {
    element.style.b ackgroundColor = '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/

    Comment

    • George Hester

      #3
      Re: Links in a applet

      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" <mahotrash@yaho o.de> wrote in message news:3fc9c516$1 @olaf.komtel.ne t...[color=blue]
      >
      >
      > George Hester wrote:
      > [color=green]
      > > 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.[/color]
      >
      > 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.javasc ript.*;
      > and you can then instantiate the JavaScript window object from Java as
      > follows
      > JSObject window = JSObject.getWin dow(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("hi ghlightLinkText ", new Object[] {"textId"});
      > Then in the HTML page write a JavaScript function
      > function highlightLinkTe xt (elementId) {
      > var element;
      > if (document.getEl ementById) {
      > element = document.getEle mentById(elemen tId);
      > if (element && element.style) {
      > element.style.b ackgroundColor = '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/
      > [/color]

      Comment

      Working...