• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

making applet talk to browser..

 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a chat applet than runs in a browser window, I would like to make the chat app "blink" when a new message arrives, like normal IM apps do... I don't think I can make browser window "blink".... but either way, first off I need to know, is there a way for the applet to somehow communicate with browser window containing it? and somehow tell browser window when a new message arrives and then I can try to bring the browser window into focus or something.. thank you very much...

-v
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The technology for having an applet "talk" to to a web page (or rather, its DOM or JavaScript) is called LiveConnect, and you can find some links on that in the AppletsFaq.
 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Veronica,
you can have the applet easily talk to the container page, and vice versa.
In order to do that, you need first to include the following library into your applet:
import netscape.javascript.*;
this library is available in your default jre
it allows you to talk to use javascript to talk to your html container page
next, you will need to add this code:
try
{
JSObject win = (JSObject) JSObject.getWindow(this);
}
catch (Exception e)
{
System.out.println("an error occured");
}
this will allow you to use the win object to call any javascript code to the container page.
and then call the win.eval function with the javascript being the parameter.
For example, If you need to access some tag in your html page, inside the win.eval call, you can use:
"document.getElementById(\"password\").disabled=false" inside the win.eval function (could not type the whole statement because javaranch assumed it was a hack attempt )
this will set a field called password to enabled
Best,
Mohammad
 
I got this tall by not having enough crisco in my diet as a kid. This ad looks like it had plenty of shortening:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic