Applet In JAVA
Java is a high-level, class-based, object-oriented programming
language that is designed to have as few implementation dependencies as
possible. Java is
computing platform first released by Sun Micro systems in 1995.
Father of java = James Goslingwhat you will read --
what is applet? advantage and disadvantage of applet.
hierarchy of applet
life cycle of java applet
applet tag
Different between applet and application programs
applet -
applet is a special type of program that embedded in the web on webpage to generate the dynamic content. It runs inside the browser and works at client side. It has less response time because it works on the client-side. It is much secured executed by the browser under any of the platforms such as Windows, Linux and Mac OS etc. There are two types of applets that a web page can contain.
advantage -
❶ It works on client side so less response time and secured
❷ It can be execute by browser running under many platforms including Linux, windows, mac OS, etc.
disadvantage -
❶ Plugin required at client browser to execute applet
hierarchy of applet -
life cycle of java applet -
life cycle methods for applets -
The java.applet.Applet class has 4 life cycle and Java.awt.component class provides 1 life cycle methods for applet.
a) Java.applet.Applet :
For creating an applet Java.applet.Applet class must inherited. It provide 4 life cycle methods
- public void init(): is used to initialized the Applet. It is invoked only once.
- public void start(): is invoked after the init() method or browser is maximized. ...
- public void stop(): is used to stop the Applet. ...
- public void destroy(): is used to destroy the Applet.
b) Java.awt.component :
public void paint(Graphics g) : used to paint the applet . Provides graphics class object that can be used for drawing ovel, ractangle, arc etc.
Applet tag :
it is used by HTML to embed the java applet code in webpage to extend the web browser capacity.
syntax :
<applet code = "url" height = "200" width = "100">.......</applet>
Note :
applet is deprecated in HTML 4.0 and not supported in HTML 5. so you can use <object> tag instead of <applet> tag.
difference between java application and java applet :
Java Application | Java Applet |
|---|---|
| Applications are just like a Java programs that can be execute independently without using the web browser. | Applets are small Java programs that are designed to be included with the HTML web document. They require a Java-enabled web browser for execution. |
| Application program requires a main function for its execution. | Applet does not require a main function for its execution. |
| Java application programs have the full access to the local file system and network. | Applets don’t have local disk and network access. |
| Applications can access all kinds of resources available on the system. | Applets can only access the browser specific services. They don’t have access to the local system. |
| Applications can executes the programs from the local system. | Applets cannot execute programs from the local machine. |
| An application program is needed to perform some task directly for the user. | An applet program is needed to perform small tasks or the part of it. |


