Define an applet name:
<applet codebase=example/ code=Sender.class width=450 height=200 name="buddy"> . . . </applet> <applet codebase=example/ code=Receiver.class width=450 height=35> <param name="name" value="old pal"> . . . </applet>
Get the applet by its name:
receiver = getAppletContext().getApplet("<applet name>");
Finding All the Applets on a Page:
Enumeration e = getAppletContext().getApplets();
An applet can ask the browser to show HTML documents:
public void showDocument(java.net.URL url) public void showDocument(java.net.URL url, String targetWindow)
Target windows:
"_blank"
Display the document in a new, nameless window.
"windowName"
Display the document in a window named windowName. This window is created if necessary.
"_self"
Display the document in the window and frame that contain the applet.
"_parent"
Display the document in the applet's window but in the parent frame of the applet.
"_top"
Display the document in the applet's window but in the top-level frame.
Applets can use networking features just as any Java program can, with the restriction that all communication must be with the host that delivered the applet to its current host.
To find from what host an applet came from:
URL hostURL = getCodeBase(); // Gets the host URL String host = getCodeBase().getHost(); // Gets the host name
Using a Server to Work Around Security Restrictions:
Copyright © 1998-2009 Dilvan Moreira