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 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:
- What is Applet
- Applet versus Application
- Understanding Applet Life Cycle
- Creating First Applet
- Drawing Shapes
- Drawing Shapes using color
- Event Listeners
- Passing Parameters To Applet
- Opening a URL from an Applet
- Opening new browser window from an Applet
- Applet not working error
- Applet Read File Example
- Applet Write Files Example
- Display image in the applet
- Play sound in applet
- Applet Security - Understanding applet security
- Swing applet Example
- Applet Banner
- Clock Applet
- Java - Opening a url in new window from an applet
- Java - Opening a URL from an Applet
In this section we have provided you many example of Applet in Java.