Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

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

 
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!
 
High Plains Drifter
Posts: 7289
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).]
 
Or we might never have existed at all. Freaky. So we should cherish everything. Even this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic