Professional Documents
Culture Documents
Applet
Applet
Introduction
• An applet is a Java program that runs in a Web browser. An applet
can be a fully functional Java application because it has the entire
Java API at its disposal.
• There are some important differences between an applet and a
standalone Java application, including the following −
• An applet is a Java class that extends the java.applet.Applet class.
• A main() method is not invoked on an applet, and an applet class
will not define main().
• Applets are designed to be embedded within an HTML page.
• When a user views an HTML page that contains an applet, the code
for the applet is downloaded to the user's machine.
Continue…………..
• A JVM is required to view an applet. The JVM can be either a plug-in
of the Web browser or a separate runtime environment.
• The JVM on the user's machine creates an instance of the applet
class and invokes various methods during the applet's lifetime..
• Advantage of Applet
• There are many advantages of applet. They are as follows:
• It works at client side so less response time.
• Secured
• It can be executed by browsers running under many platforms,
including Linux, Windows, Mac Os etc.
• Drawback of Applet
• Plugin is required at client browser to execute applet.
Two Types of Applets
• The first are those based directly on the Applet class. These
applets use the Abstract Window Toolkit (AWT) to provide the
graphic user interface (or use no GUI at all).
• The second type of applets are those based on the Swing class
JApplet. Swing applets use the Swing classes to provide the GUI.
Swing offers a richer and often easier-to-use user interface than
does the AWT.
Applet Basics
• All applets are subclasses (either directly or indirectly) of Applet.
Applets are not stand-alone programs. Instead, they run within
either a web browser or an applet viewer.
• Execution of an applet does not begin at main( ).
• Output to your applet’s window is not performed by
System.out.println( ). Rather, in non-Swing applets, output is
handled with various AWT methods, such as drawString( ), which
outputs a string to a specified X,Y location.
• To use an applet, it is specified in an HTMLfile. One way to do this
is by using the APPLET tag.
The Applet Class
Applet Architecture
•Four methods in the Applet class gives you the framework on which you
build any serious applet −