Applet/HTML interaction

Discussion in 'Java' started by Rhino, Jan 29, 2006.

  1. Rhino

    Rhino Guest

    I've written my share of applets but I've never really done very much in the
    way of interacting with an applet via the HTML on the page containing the
    applet. I'm hoping someone can suggest a way to accomplish what I want to
    do.

    I'm helping a friend who needs a Java applet for his website. He wants to
    display a page containing a paragraph or two of English. Some of the words
    in the paragraphs will be ones that people may not know how to pronounce so
    he wants visitors to the page to be able to click on the word and have an
    applet play a sound file that illustrates the proper pronunciation. So, if
    the paragraph was "One of the most visited spots in London is the Leicester
    Square, which is located some distance from Beaulieu Wood.", the person
    clicking on "Leicester" would hear the applet say "Lester" and the person
    clicking on "Beaulieu" would hear the applet say "Bewley".

    I've already got code that will play the a sound file so I don't need help
    with that. However, I'm not sure how to organize things so that I can have a
    single occurrence of the applet on the page and make a click on a given word
    in the paragraph invoke the playing of the proper audio file in the applet.

    I realize that it would be simpler to make a separate instance of the applet
    for each word that needs to be pronounced and I'm willing to do that if it
    becomes necessary but I'm hoping someone can suggest an elegant way for the
    applet to simply play the sound corresponding to the word clicked.

    Any ideas how I can do what I want to do?

    --
    Rhino
    Rhino, Jan 29, 2006
    #1
    1. Advertising

  2. Rhino

    zero Guest

    "Rhino" <> wrote in
    news:MZ3Df.48$:

    > I've written my share of applets but I've never really done very much
    > in the way of interacting with an applet via the HTML on the page
    > containing the applet. I'm hoping someone can suggest a way to
    > accomplish what I want to do.
    >
    > I'm helping a friend who needs a Java applet for his website. He wants
    > to display a page containing a paragraph or two of English. Some of
    > the words in the paragraphs will be ones that people may not know how
    > to pronounce so he wants visitors to the page to be able to click on
    > the word and have an applet play a sound file that illustrates the
    > proper pronunciation.


    <snip>

    > Any ideas how I can do what I want to do?
    >


    I would suggest you don't use an applet at all, but instead use raw html,
    or maybe JavaScript. Make the words that are clickable links to a sound
    file (or JavaScript code that plays a sound file). I think it would be
    easier to code, easier to understand for the users, and a hell of a lot
    easier to maintain.
    zero, Jan 29, 2006
    #2
    1. Advertising

  3. Rhino

    Roedy Green Guest

    On Sun, 29 Jan 2006 09:06:58 -0500, "Rhino"
    <> wrote, quoted or indirectly
    quoted someone who said :

    >I'm helping a friend who needs a Java applet for his website. He wants to
    >display a page containing a paragraph or two of English. Some of the words
    >in the paragraphs will be ones that people may not know how to pronounce so
    >he wants visitors to the page to be able to click on the word and have an
    >applet play a sound file that illustrates the proper pronunciation. So, if
    >the paragraph was "One of the most visited spots in London is the Leicester
    >Square, which is located some distance from Beaulieu Wood.", the person
    >clicking on "Leicester" would hear the applet say "Lester" and the person
    >clicking on "Beaulieu" would hear the applet say "Bewley".


    the easy way to do that is with an applet that displays the word. When
    you click it, it pronounces it. that would work fine if there are
    just a few words per page to deal with. You might want to use static
    html macros to generate the <applet tags. That is how I do CurrCon to
    display variable currencies on a page. You change the country and
    instantly the whole pages converts to that currency. The applets
    inform each other of any changes they detect.

    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Java custom programming, consulting and coaching.
    Roedy Green, Jan 29, 2006
    #3
  4. Rhino

    Roedy Green Guest

    On Sun, 29 Jan 2006 09:06:58 -0500, "Rhino"
    <> wrote, quoted or indirectly
    quoted someone who said :

    >I'm helping a friend who needs a Java applet for his website. He wants to
    >display a page containing a paragraph or two of English. Some of the words
    >in the paragraphs will be ones that people may not know how to pronounce so
    >he wants visitors to the page to be able to click on the word and have an
    >applet play a sound file that illustrates the proper pronunciation. So, if
    >the paragraph was "One of the most visited spots in London is the Leicester
    >Square, which is located some distance from Beaulieu Wood.", the person
    >clicking on "Leicester" would hear the applet say "Lester" and the person
    >clicking on "Beaulieu" would hear the applet say "Bewley".

    The hard way to do this is with DOM/LiveConnect/JavaScript

    See http://mindprod.com/jgloss/dom.html
    http://mindprod.com/jgloss/javascript.html
    http://mindprod.com/jgloss/liveconnect.html
    and chase links.
    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Java custom programming, consulting and coaching.
    Roedy Green, Jan 29, 2006
    #4
  5. Rhino

    Roedy Green Guest

    On Sun, 29 Jan 2006 14:57:03 GMT, zero <> wrote, quoted or
    indirectly quoted someone who said :

    > would suggest you don't use an applet at all, but instead use raw html,
    >or maybe JavaScript. Make the words that are clickable links to a sound
    >file (or JavaScript code that plays a sound file). I think it would be
    >easier to code, easier to understand for the users, and a hell of a lot
    >easier to maintain.


    see http://mindprod.com/esperanto/esounds.html
    for a example of that technique.
    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Java custom programming, consulting and coaching.
    Roedy Green, Jan 29, 2006
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?UHJpeWE=?=

    interaction between aspx & html page

    =?Utf-8?B?UHJpeWE=?=, Oct 18, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    466
    Patrice
    Oct 18, 2004
  2. Archana
    Replies:
    1
    Views:
    1,365
    Andrew Thompson
    Oct 25, 2004
  3. For Example: John Smith

    onClick interaction with applet in Mozilla

    For Example: John Smith, Aug 19, 2003, in forum: Javascript
    Replies:
    2
    Views:
    219
    Laurent Bugnion, GalaSoft
    Aug 19, 2003
  4. Gruupy
    Replies:
    0
    Views:
    275
    Gruupy
    Aug 15, 2006
  5. Ernesto

    Applet Interaction with JS

    Ernesto, Nov 4, 2007, in forum: Javascript
    Replies:
    4
    Views:
    137
    Richard Maher
    Nov 8, 2007
Loading...

Share This Page