Back Button
Back to Chapter
No items found.
Table of Contents

Applets are small Java programs that are primarily used in internet computing. They can be transported over the internet from one computer to another and run using the Applet Viewer. It can perform arithmetic operations, display graphics, play sounds, accept user input, create animations.

1.Types of Applets:

There are two types of applets in java:

i) Local Applet

ii) Remote Applet

i) Local Applet:

An applet developed locally and stored in a local system is known as a local applet. When a web page is trying to find a local applet, it does not need to use the internet and therefore the local system does not require the internet connection.

ii) Remote Applet:

A remote applet is that which is developed by someone else and stored on a remote computer connected to the internet. If our system is connected to the internet, we can download the remote applet onto our system via the internet and run it. In order to locate and load a remote applet, we must know the applet's address on the web. This is known as Uniform Resource Locator (URL).

CODEBASE  = https  :  //  / applets

2. Steps Involved in developing and testing in applets:

Before we try to write applets, we must ensure that java is installed properly and ensure that either the Java applet viewer or a Java-enabled browser is available. The steps involved in developing and testing in applets:

3. Building APPLET code:

The Applet class is contained in java.applet package provides an application, where java calls the main() method directly to initiate the execution of the program, when the applet is loaded. The paint() method of the Applet class, when it is called, actually displays the result of the applet code on the screen.

public void paint(Graphics g) // paint() method requires Graphics class with object g


import java.awt.*;
import java.applet.*;
public class HelloWorld extends Applet{
  public void paint(Graphics g){
    g.drawString("Hello World", 10, 100); // 10 as width and 100 as height
Hello World*/
//positioned at 10 pixels at the width and 100 pixels at height