Need example of getAppletContext with AWT applet !!

Can anyone please post a simple code
which will explain to me
how sohuld i use the getAppletContext
Neta :}

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


check the docs

public abstract void showDocument(URL url)
Replaces the Web page currently being viewed with the given URL. This method may be ignored by applet contexts that are not browsers.
url - an absolute URL giving the location of the document.

 public abstract void showDocument(URL url, String target)
Requests that the browser or applet viewer show the Web page indicated by the url argument. The target argument indicates in which HTML frame the document is to be displayed. The target argument is interpreted as follows:

Although an applet is stopped and the page containing it is pushed in the history, the applet may refuse to suspend itself. Some applets do this so that they can continue to provide a service to the user even after the page is left. Often these applets will put up their own top-level window (an AWT Frame) in which they will continue to display information. Also, they will often have another background thread which will continue running even after the applet transitions to Stopped, and the applets main window on the HTML page is made invisible.

However, there is a limitation that once the applet is stopped, showDocument will no longer function, even if a background thread attempts to use it. Attempting to call showDocument will silently fail. When the applet transitions back to the started state, showDocument will again be functional.

Before we fix this limitation, we need to define what the behavior of showDocument will be with respect to targeting particular frames, given that those frames (e.g. _self) may no longer exist. However, given the desire to allow some form of background tasks to call showDocument, we hope to fix this behavior in a future release. 

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
I posted as a comment, because vladi21 is very quick :)

An applet runs inside a browers such as Netscape, IE or appletviewer. An applet can ask the browser to do things for it, for example to fetcht an audio clip, show a short messages in the status line, show a different web page and etc. If you use applet viewer for certain task above, it won't work.
To communicate with the browsers, an applet call the getAppletContext mehtod. The method returns an object of type AppletContext.

for example :
to show different webpage
 URL u = new URL ("");

hope this helps

Hi neta,

  Above both comments are fine. Thye explained to show a document. I am explaining Applet-Applet communication.

 getAppletContext() will be useful for getting applet-applet communication which are resinding on same web page.

 AppletContext ac = getAppletContext();
 ac.getApplet("anotherappletname"); returns a applet for which the "anotherappletname" string is given by browser.

In that case you have to chage  applet tag as follows

<Applet code="somex.class" height=200 width=200 name="somename"></applet>

for each applet which is residing on same web page, give a  name and you can use that name in appletcontext's getApplet()

 after this you can call methods of someotherapplets.

Best of luck
netaAuthor Commented:
Thank you all

you have help me alot

keep on the good job

Neta :}
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.