What is an Applets?
Hi Friends
What is an Applets?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Satyapriya NayakPosted Oct 23, 2012, 1:06 PM
Applet
This is a program, which can create graphical user interface to make visible dynamic content in the web browser. It creates a window for the web content visible inside the web browser. The compiled java program can be loaded into the web browser with the help of html document. To execute the applet in the web browser it must contain java virtual machine. The applet can deal with presentation logic and business logic. An applet does not have main method as the starting point of the execution.
Creation process of applet
1.Create a class by inheriting java applet. Applet class.
2.Override the life cycle method of applet such as init (), start (), stop (), destroy () and provide presentation with business logic into these methods.
3.Create a html file, which must contain the
4.Compile the file and load the html file into the browser.
5.Using applet viewer tool available in jdk can test an applet corresponding html file.
Life cycle of applet
It is of five types
1.Init()
2.Start()
3.Paint()
4.Stop()
5.Destroy()
Init():- This is a method which initializes the applet with the required components inside it. This method executes only once of the life cycle of an applet.
Start():- This method is responsible for activating the applet. This method executes when applet will be restored or visible in the web browser. This method executes more than once in the life cycle of an applet.
Paint():- This method can be used to draw different components or graphical shape into the applet. This method can be executed repeatedly during the applet execution.
Stop():- When an applet will be minimized or made invisible by using back or forward button of the web browser then the applet will be deactivated by calling this method.
Destroy():- When the browser containing the applet will be closed then this method will be called. This method execute only once in the life cycle of an applet.
Ex:- lifecycle of applet
import java.applet.*;
import java.awt.*;
public class life extends Applet
{
public void init()
{
setBackground(Color.yellow);
setFont(new Font("",Font.BOLD,30));
Label lab1=new Label("lifecycle Applet");
add(lab1);
System.out.println("Init called");
}
public void start()
{
System.out.println("start called");
}
public void paint(Graphics g)
{
System.out.println("paint called");
}
public void stop()
{
System.out.println("stop called");
}
public void destroy()
{
System.out.println("destroy called");
}
}
/*
*/
Compile
javac life.java
appletviewer life.java
Thanks
If this post helps you mark it as answer
Shivanand ArurPosted Oct 23, 2012, 7:21 AM
http://en.wikipedia.org/wiki/Applet
Sivaraman DhamodaranPosted Oct 23, 2012, 7:01 AM
Vithal WadjePosted Oct 23, 2012, 6:45 AM