Survey
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
Applets
1. Applets are JAVA programs that run on a web browser or an applet viewer.
2. Since applets run inside a Java enabled browser, some of the work of creating
a user interface is already done for the programmer. A window for the applet
to run in, mechanisms for display of graphics, and for the receipt of
information are all already available.
3. Java applets run under strict security rules on Netscape and Internet Explorer:
a. They cannot read or write files on the user’s file system.
b. They cannot communicate with an internet site other than the one that
served the web page that included the applet.
c. They cannot run any programs on the reader’s system.
d. They cannot load programs stored on the user’s system.
4. Applets do not have a main() method, in contrast with Java applications.
5. All applets are subclasses of the Applet class in the Java.applet package
6. The Applet class provide two kinds of behaviors:
a. Behavior to work as part of a browser and handle occurrences such as
the reloading of a browser page.
b. Behavior to present a GUI and accept input from users.
7. The Applet class is what triggers the execution of applets. The standard
statement to ensure this execution is:
Public class yourApplet extends java.applet.Applet
{
}
8. All applets must be declared as public because Applet is a public class. This
is required only of the main applet class; other helper classes may be public or
non public.
9. Important applet methods are:
a. The init() method. This is what creates the objects that the applet
needs, sets up an initial state, loads images and fonts, sets parameters.
If the defaults are acceptable , the user defined applet need not include
the init method.
public void init()
{
}
is the form of the method.
b. Applets are started after they are initialized or stopped. While
initialization can happen only once, starting can happen many times.
The form is:
public void start ()
{
}
c. Stopping occurs whenever the user leaves the page that contains a
currently running applet. However, any threads the applet has started
running continue. Stop() can be used to suspend execution of these
threads and use start(0 to restart them. The form is:
public void stop()
{
}
d. Running threads can be killed and memory freed once the applet
terminates by using destroy().
e. The first four methods are automatically called by JAVA; though, they
can be over-ridden by redefining the method in your applet.
f. In order to display anything on the applet window, the paint() method
must be used. The form is:
public void paint(Graphics g)
{
}
To run the paint() method the applet must have imported the Graphics
class using:
Import java.awt.Graphics;
g. Java applets run on a web browser only if embedded into an html
defined web page. The following format can be generally used:
<HTML>
<HEAD>
<TITLE> This is just a title for My Applet Window </TITLE>
</HEAD>
<BODY>
<P> This is just a heading in the applet window</P>
<APPLET CODE = "Class1.class" height=256 width=562 >
</APPLET>
</BODY>
</HTML>
The maximum window size for your applets should be about 600 X 400 to allow most
formats, such as VGA, SVGA etc., to display the entire applet in addition to the
browser’s menu bars etc.
h.