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

Invoke a method of an applet from another applet in the same page.

 
Nigel Chou
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I try to invoke a public motherd of an applet (AppletA) from another applet(AppletB) in the same page.
The code in AppletB:
JSObject win, top, doc, frame, softPhone;
win = JSObject.getWindow(this);
System.out.println("win:" + win);
top = (JSObject)win.getMember("top");//OK, get the top window
System.out.println("top:" + top);
frame = (JSObject)top.getMember("softphoneFrame");//OK, "softphoneFrame" is the name of the frame where AppletA is
System.out.println("frame:" + frame.getClass().getName());
softPhone = (JSObject)frame.getMember("AppletA");//To get the reference to AppletA, ERROR,
//Because frame.getMember("AppletA") is NOT a JSObject BUT a instance
//of sun.beans.ole.OleAppletViewerInterface
System.out.println("softPhone:" + softPhone.getClass().getName());
String[] args = {"MONITOR", "7404"};
softPhone.call("pbx_monitor_work",args);
<B>
Where can I get the document explaining how to use the class: sun.beans.ole.OleAppletViewerInterface? </B>
Thanks in advance!
 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found a thread at the Java Developer's Connection where some other people ran into the same problem. The common symptom appears getting JSObject to behave, and getting more info on this class you mentioned.
Here's another approach that is also a more general solution: Applet objects can access their browser environment through getAppletContext(). You can use the returned AppletContext reference to call getApplet() or getApplets(), and from there call the method you want on the applet object in question.
I haven't outlined the whole procedure, obviously, as I haven't used it in over a year. But I had no troubles with that approach, or at least none worth remembering.
Good luck!
------------------
Michael Ernest, co-author of: The Complete Java 2 Certification Study Guide
[This message has been edited by Michael Ernest (edited December 31, 2001).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic