Saturday, February 12, 2011

Java Applet Tutorial

Java applets on the net are restricted from reading and writing files on the client file system, it also prevent making network connections excluding, to the origin host. It supports for an expanded set of Jar-file manifest attributes. HTTP server does not serve any java applets .but  On server’s side they are treated as any file, such as a text, image, or sound file. Special action is done when the class files of applet are interpreted on the client side by a Java technology-enabled browser, for example 1.x  or HotJava browser or or Netscape 3.x/4.x.


Applets are able to read system properties by using: String ss = ystem.getProperty(String key):

Applets are forbidden reading system properties like java.home, user.name, user.home,
user.dir, java.class.path

For writing a chat applet and to put icons in user messages. Add image (jpg or gif) into html code and it will display your icons in text area.

One applet can load another applet. Both applets should be in the same page. But  both the applets will load independently. Control the behaviour of the other applet from the first one. But your requirement is of loading another applet from the first one. You can have two frames in a page. In one frame there will be your first applet which will load automatically when the page is loaded. And the other frame will contain a blank page. Now on certain event in the first applet use "this.showDocument("URL") " to make a call to another applet which you want to load. Give the target parameter as the other frame. (You will have to give the name of the other frame) Now when these two applets are loaded they can exchange data in their life time."

The applet tag’s attribute shows the browser info regarding applet. The only necessary attributes are CODE (or OBJECT), WIDTH, and HEIGHT.
Attribute are as under;
CODEBASE = codebaseURL
This OPTIONAL attribute specifies the base URL of the applet--the directory that
includes the applet's code. If this attribute is not specified, then the document's URL
is used.
ARCHIVE = archiveList
This OPTIONAL attribute describes one or more archives containing classes and other
resources that will be "preloaded". The classes are loaded using an instance of an
AppletClassLoader with the given CODEBASE.

No comments:

Post a Comment