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?
vladi21Connect With a Mentor Commented:

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. 
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 :}
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.