4. “Applet is a special type of
program that is embedded in the
webpage to generate the
dynamic content.
44
5. Continued..
▰ It runs inside the browser and works at client side.
▰ Applets in Java are small and dynamic internet-based programs.
▰ Plug-in is required at client browser to execute applet.
▰ It works at client side so less response time.
▰ A Java Applet can be only executed within the applet framework of Java.
5
6. Why we use Applets
▰ Java Applets are usually used to add small, interactive
components or enhancements to a webpage. These may consist
of buttons, scrolling text, or stock tickers, but they can also be
used to display larger programs like word processors or games.
6
9. Example
9
import java.applet.Applet;
import java.awt.Graphics;
public class HelloWorld extends Applet
{
public void paint(Graphics g)
{
g.drawString("Hello World!", 50, 25);
}
}
<html>
<head>
<TITLE> A Simple Program</TITLE>
</head>
<body> Here is the output of my
program:
<applet code="HelloWorld.class"
width="150" height="25"></applet>
</body>
</html>
10. Advantages & Disadvantages
Advantage
▰ It is simple to make it work on Linux,
Windows and Mac OS i.e. cross platform.
▰ The same Applet can work on all installed
versions of JAVA at the same time.
▰ It can move the work from server to the
client.
▰ Secured:- An un-trusted applet has no
access to the local machine and can only
access the server it came from.
▰ Java applets are fast.
Disadvantage
▰ It requires the java plug-in.
▰ Some browsers, notably mobile
browsers like Apple iOS or Android
do not run the java applets at all.
▰ Some applets require a specific JRE.
10