Java Applet Basics Tutorial

« Previous Tutorial Next Tutorial »

Java Applet

Java applets are developed in Java language.

In Java, an applet is a program that runs in a Web browser. An applet can be a fully functional Java application because it has full Java API at its disposal.

A Java applet is a small Java program that runs inside another program such as web browser. Both Internet Explorer and Netscape navigator can run Java applet. Java applets are embedded into web pages to rotate images for animations and to access database on the internet.

Java Applet Example

The following is a simple applet named

/* Java Program Example - Java Applet Basics */
import java.applet.*;
import java.awt.*;

public class HelloWorldApplet extends Applet
   public void paint (Graphics g)
      g.drawString ("Hello World", 25, 50);

Compile and Execute Java Applet Program

This is for BlueJ user. To compile and execute an applet program/application, follow these steps:

java applet

Now provide 200 in height box, and 400 in width box and now click on OK button, and watch the output as shown here.

Here is the output window of the above applet program of 400 width and 200 height.

java applet tutorial

Here are the two import statements in Java, that brings the classes into the scope of our applet class in Java:

Java Online Test

« Previous Tutorial Next Tutorial »

© Copyright 2021. All Rights Reserved.