What is Applet in Java?
A small application written in Java programming language is embedded into a web page known as applet. For example, applets can be used to provide a level of interactivity that is not possible with simple HTML pages. Applets can also be used to create highly customized user interfaces. The applet is hosted on a web server and works on the client-side. Local applet and remote applet are the two types of applets.
Local applet is designed and stored in the user’s computer where as remote applet is designed by other developers and stored in a remote computer that is connected to the internet.
Advantages of Applets:
- Applets can perform a variety of small tasks on the client system, such as displaying images, playing sounds, receiving user input, and receiving mouse clicks.
- Downloads are not delayed because applets are cached fast. Applet files are often small and quick to download.
- Applets are secure and safe to use because they can’t change the local system in any way.
- This is platform independent code so it can run in any browser.
- Applet program work on the client side and provides faster response times.
Disadvantages of Applets:
- Applets have no access to client-side resources such as files or the operating system.
- Applets cannot work with load libraries or native methods.
- Applets can only extract information about the client system, such as name, Java version, OS, and version.
- Applets must be tagged as trusted applets and registered with APS (Applet Security Manager).
Applet Life cycle Methods:
- init() – init() method is used to initialize an applet.
- start() – After the init() method has been invoked or the browser has been maximised, start() is called. It is used to start the Applet.
- stop() – The stop() method is used to stop the applet. This is called when the browser is closed or minimised, or the application crashes unexpectedly.
- destroy() – destroy() method is used to destroy the Applet. It is invoked only once.
- paint() – The paint() method can be used to paint any shape, including squares, rectangles, trapezoids, eclipses, and so on. ClassGraphics is an argument in the paint() method.
What is the best way to operate Applet in Java?
There are two standard ways to run an applet in Java:
- By using an HTML file.
- By using an applet viewer. Applet viewer executes the applet in a window and it is generally the fastest and easiest way to test the applet.
Here’s a list of Applet programming in Java. Each example program includes a program description, Java code, and program output. All examples have been compiled and tested on Windows and Linux systems.
Here is the listing of Java Applet Programs:
|Create Java Applet||Java Program to Create a Basic Applet|
|Display Image using Applet in Java||Java Program to Display Image using Applet|
|Create Banner Using Applet in Java||Java Program to Create a Banner using Applet|
|Create & Fill Shapes using Applet in Java||Java Program to Create and Fill Shapes using Applet|
|Opening a Link from an Applet in Java||Java Program to Go To a Link using Applet|
|Play Audio using Applet in Java||Java Program to Play Audio using Applet|
|Display Clock in Java Applet||Java Program to Display Clock using Applet|
|Display Human Face in Java Applet||Java Program to Display Human Face using Applet|
|Display Pie Chart using Frame in Java||Java Program to Display a Pie Chart using Frame|
|Simple Calculator Program using Java Applet||Java Program to Demonstrate a Basic Calculator using Applet|
|Read & Write File Operations using Java Applet||Java Program to Perform Read and Write File Operations using Applet|
|Create Transparent Cursor in Java||Java Program to Create a Transparent Cursor|
|Find Square Root using Java Applet||Java Program to Find Square Root using Applet|
|Vector Class Method in Java||Java Program to Show the use of Methods of Vector Class|
|URL Class in Java||Java Program to Show the use of Various Methods of URL Class|
|Check Antialiasing is Enabled or Not in Java||Java Applet Programs to Check Whether Antialiasing is Enabled or Not|
|Create Java Applet to Simulate Sorting Technique||Java Program to Create Applet to Simulate Any Sorting Technique|