Applet

Dec 12 • Notes • 1848 Views • No Comments on Applet

An applet is a Java program that runs on a Web browser. It is actually a small application program that performs a specific task assigned to it. It can be a fully functional Java application because it has the entire Java Application programming interface. Although it is not a fully featured application program. These are intended to be accessed easily by the users. It is a Java class that extends the “java.applet.Applet” class. These are designed to be embedded within an HTML page to get it accessed. When a user views an HTML page that contains it, the code for it is downloaded to the user’s machine. A java virtual machine or JVM is required to view it. The Java Virtual Machine or JVM on the user’s machine creates an instance of the applet class and invokes various the methods during it’s lifetime. So it is basically a Client Side program. The Life cycle of it is defined by the four methods. AppletThose four methods are:

  • init: This method is intend for whatever initialization is needed for our applet. This is the starting method for the program.
  • start: This method is automatically called after the browser calls the init method.
  • stop: This method is automatically called when the user moves off the page on which the applet sits.
  • destroy: This method is only called when the browser shuts down normally. Because applets are meant to live on an HTML page, you should not normally leave resources behind after a you leave the page that contains the applet.
  • paint: This method is invoked immediately after the start() method. The paint() method is actually inherited from the “java.awt” package. The “awt” is a package in the java. Every applet is an extension of the “java.applet.Applet” class. The base class of it provides methods that a derived class of it may call to obtain the information and the services from the browser context.

This is the small applet code in html. The applet tag generally used is <applet>. We should use this tag in the starting or beginning of the body and then at last where body ends along with a backslash “/”.

<html>
<title>The Hello, World Applet</title>
<hr> <applet code=”HelloWorldApplet.class” width=”320″ height=”120″> “Hello, World” </applet> </hr>
</html>

Recent developments in the coding of the applications for mobile and embedded systems pointed out the need for more security of the applets. Generally the security models which it contains are:- unsigned Java applet security, signed Java applet security, and self signed Java applet security. There security of it is more of the concern because there are many such malicious programs and these can harm the computer system in many ways like denial of service, invasion of privacy, annoyance, etc. Though there exists some programs which provides security from the malicious programs.

I hope I was able to clear out this topic. If you still have any doubt or query regarding this topic, you can place those in the comment box below. You are also most welcome to share your views and suggestion with us here.

Tell us Your Queries, Suggestions and Feedback

Your email address will not be published.

« »