Sunday, March 6, 2011

Java's Applets

Applet is a small program or utility in Java that requires small amount of resources for it to run. And, with this restricted size, it can only do a little to perform. We can actually embed applets in our Java program and run it using Java's Applet Viewer or in an HTML document with corresponding browser.

Applet is an object, component and container and with these features, we can do much of the works and features of typical component, container or object.

We support an applet using java.applet package and depending on the type of components, we invoke the needed package, javax.swing for swing applet and components or java.awt for awt applet and components.

Unlike a regular Java program, an applet does not require a main method. The Applet Viewer or the HTML document allows the execution of Java applet.

The sample program below illustrates the use of applet.
[+/-] show/hide

* To change this template, choose Tools | Templates
* and open the template in the editor.
import java.applet.*;
import java.awt.Color;
import java.awt.Font;
import java.awt.*;
* @author Rose
public class AppletGreet1 extends Applet {
Label greeting = new Label("Hello world");
Font myFont = new Font("Arial",Font.BOLD,50);
public void init()



No comments: