Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

making applet talk to browser..

 
Veronica Damian
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • 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
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • 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.
 
Mohammad Farhat
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic