What is Applet in Java with Example?

In this section we are explaining you the Applet concept and you will understand What is Applet in Java with Example code?

What is Applet in Java with Example?

In this section we are explaining you the Applet concept and you will understand What is Applet in Java with Example code?

What is an Applet

What is Applet in Java with Examples?

In this section we are going to learn the Applet in Java. In Java Applet are special Java program that runs on the Java enabled web browser. Applet allows the developer to create GUI application using the Swing components. This makes applet just like desktop application that runs on the browser.

Applet program is hosted on the web server and its jar file is downloaded form the server before running in the Java Enabled web browser. Applet can be used to create various types of applications including animation applets.

Applet program can be signed with the cryptography keys to make it secure. There are restriction on the Applet as it is downloaded from the internet and requires to be compliant with Internet security standard.

Introduction

Applet is Java program and its jar files are distributed from the web sever, it is embedded into HTML page and runs on the web broser. Java applets runs on the java enables web browsers such as mozila and internet explorer. Applet is designed to run remotely on the client browser, so there are some restrictions on it. Applet can't access system resources on the local computer. Applets are used to make the web site more dynamic and entertaining.

You can create Applet by extending your class with Applet class. Here is simple example of Hello World applet:

import java.applet.*;
import java.awt.*;

public class FirstApplet extends Applet{
  public void paint(Graphics g){
  g.drawString("Welcome in Java Applet.",40,20);
  }
}

You have to compile this class into a class file and then embedded in HTML page. Check Creating First Applet for quick example of coding, compiling and running an Applet.

To run Applet in browser you have you use Java enabled web browser. Here are examples of Applet:

  1. What is Applet
  2. Applet versus Application
  3. Understanding Applet Life Cycle
  4. Creating First Applet
  5. Drawing Shapes
  6. Drawing Shapes using color
  7. Event Listeners
  8. Passing Parameters To Applet
  9. Opening a URL from an Applet
  10. Opening new browser window from an Applet
  11. Applet not working error
  12. Applet Read File Example
  13. Applet Write Files Example
  14. Display image in the applet
  15. Play sound in applet
  16. Applet Security - Understanding applet security
  17. Swing applet Example
  18. Applet Banner
  19. Clock Applet
  20. Java - Opening a url in new window from an applet
  21. Java - Opening a URL from an Applet

In this section we have provided you many example of Applet in Java.