In Focus
Delhi Chapter Hands On June 22: Limited Seats Register Now
Kolkata Chapter Developer Day: May 25
C# Corner Delhi Chapter Meet, May-18, 2013 Official Recap
Istanbul Chapter May 2013 2nd Seminar Announced : Learn WinJS, Windows Store, MVC
Email :
Password :
Remember me?
Forgot password
Contribute
An Article
A Blog
A News
A Video
A Link
An Interview Question
Ask a Question
TECHNOLOGIES
.NET 4.5
Current Affairs
Learn .NET
SharePoint 2010
Web Development
.NET Assemblies
Databases & DBA
LightSwitch 2012
SharePoint 2013
Web Services in C#
ADO.NET in C#
Design & Architecture
LINQ
Silverlight with C#
Windows 8
AJAX in C#
Exception Handling C#
Mobile & Embedded
Smart Devices
Windows Azure
Android Programming
Graphics Design
Office 2013
SQL
Windows Controls C#
Articles C#
Hardware
OOP/OOD
SQL Server 2012
Windows Forms C#
ASP.NET Controls in C#
How do I
Operating Systems
Testing
Windows Phone 8
ASP.NET MVC with C#
HTML 5
PHP
TypeScript
Windows Server 2012
ASP.NET Programming
Internet & Web
Products
Visual C#
Windows Store Apps
C# Language
iPhone/iPad
Project Management
Visual Studio .NET
Workflow Foundation in C#
C# Tutorials
Java
Reports using C#
Visual Studio 2010
WPF
C, C++, MFC
Java and .NET
Robotics & Hardware
Visual Studio 2012
XAML
Career Advice
JavaScript, CSS
Security in .NET
WCF with C#
XML
Chapters
JQuery
Request a new Category
|
View All
ANSWERS
BLOGS
VIDEOS
INTERVIEWS
BOOKS
LINKS
NEWS
CHAPTERS
CAREER ADVICE
Making your Web Browser in C#
HTML 5 vs Native Apps
Secure Your Android Application from Hackers
Why to fear Object Oriented Programming approach
Check upcoming B'day in Asp.net
Happy Birthday Destin Joy
Difference between IEnumerable and IEnumerator
Compare strings using StringComparison.Ordin ...
Class vs Structure
Import Email from Gmail in ASP.NET
Blog
Java Applets and its life-cycle
Posted by
Satyapriya Nayak
in
Blogs
|
Java
on
Sep 28, 2011
In this blog we will know about the java applets and its life cycle.
Tweet
2504
0
0
Download Files:
Life cycle.rar
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
Create a class by inheriting java applet. Applet class.
Override the life cycle method of applet such as init (), start (), stop (), destroy () and provide presentation with business logic into these methods.
Create a html file, which must contain the <Applet> tag to load applet into the web browser.
Compile the file and load the html file into the browser.
Using applet viewer tool available in jdk can test an applet corresponding html file.
Life cycle of applet
It is of five types
Init()
Start()
Paint()
Stop()
Destroy()
I
nit():
- 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");
}
}
/*
<applet code="life" height="200" width="200">
</applet>
*/
Compile
javac life.java
appletviewer life.java
After closing the applet window stop() is called first and then destroy() method finally execute which is shown below in the console.
This Feature is Sponsored By
DynamicPDF Merger is a developers dream for interacting with any existing PDF documents. Merge, append, split, form fill, flatten stamp and so much more.
Servlet Chaining using request d..
Comparing equality of Strings in Java
post comment
COMMENT USING
PREMIUM SPONSORS
iPhone, Android & Web Development Services
Over-C is a holistic consortium of communications and technology specialists. We build, deploy and market both business as well as consumer products and solutions.
More Blogs from this Blogger
Validate TextBox using JavaScript
Display XML File Data into GridView using DataTable
Search Record Display in GridView
Display Data from Database to Label
Delete multiple row by selecting checkbox on Data Gridview
Update Male TO Female and Female To Male with single query
Display username belong to selected item value from combo box
Related records from one textbox to another
Fetch multiple items to combobox from db
Uncheck CheckBoxList items when button is clicked
View All
SPONSORED BY
DynamicPDF ReportWriter Suite
PDF reports have never been easier to create. With our included WYSIWYG Designer, you can layout your reports, set up your data source and let DynamicPDF ReportWriter do the rest.
Follow @twitterapi
Latest Blogs
Mathematical Symbols in Views
Restricting numeric value in Textbox
Creating Inner Join on Multiple Tables in SQL Server
Bind GridView with MS Access Database Table in ASP.NET
Difference between IEnumerable and IEnumerator
Project Cost Estimation
Basic Aspects of Security and Control
Zoom Image in Different Way in ASP.NET
Gridview with checkbox with check all option
Download SAP Crystal Reports for Visual Studio 2010 - Its Free
View All
Poll
Result
All Polls
What is the best product to build Mobile apps?
What is the best product to build Mobile apps
PhoneGap
Icenium
Xamarin Studio
KendoUI Mobile
JQueryMobile
Native iOS/Android
What is the best product to build Mobile apps
Options
Votes
%
PhoneGap
2
2.74
Icenium
0
0.00
Xamarin Studio
1
1.37
KendoUI Mobile
1
1.37
JQueryMobile
61
83.56
Native iOS/Android
8
10.96
Total
73
100%