×
FREE ASSISTANCE FOR THE INQUISITIVE PEOPLE
Tutorial Topics
X
softetechnologies
Java Mixed Programs Java Examples : Frequency of the character in a paragraph
Java Applet Basic - Java
4785    Arnab De    17/08/2017

Lifecycle of Java Applet

In the Java Applet, all the methods are called sequentially. The sequences of the methods are

  • init() : This method called ones in the applet life cycle. When an applet run then this method initialized required variables.
  • start() : This method automatically invoked after init(). In this method start all the required services and it calls the paint methods automatically.
  • paint() : This method receives a Graphics object as paint all the data in applet form.
  • stop(): This method used to stop all the running services of the Applet.
  • destroy() : This method destroys all the memory space which is allocated by the applet.

This is called life cycle of the applet.

softetechnologies

Basic structure Of An Applet Program

import java.awt.*;
import java.applet.*;

/*<applet code=" BasicApplet " width=300 height=100></applet>*/

public class BasicApplet extends Applet
{
public void init() {}
public void start() {}
public void paint(Graphics g) {}
public void stop() {}
public void destroy() {}
}

All the function is mandatory to run an Applet but only required will be overridden by the user.

Basic program

import java.applet.*;
import java.awt.*;

/* <applet width=400 height=200 code="AppletOne.class"></applet> */

public class AppletOne extends Applet

{

public void paint(Graphics g)

{

g.drawString("Tutorial At Home",100,100);

}

}

softetechnologies

To Run this program

  • Compile the program by javac AppletOne.java
  • Run program appletviewer AppletOne.java

Video Tutorials

Every program of applet should inherit from the super class Applet. We can also show the status bar in the window by using the method showStatus(). To runtime drawing in the applet window we must call the redraw() methods. To draw different shape in applet window we can also use the following methods.

softetechnologies

drawLine()

Draw a line from first coordinate to last coordinate.

drawRect()

Draw a rectangle by left top coordinate and given width and height.

fillRect()

Draw a rectangle by left top coordinate and given width and height. And fill it by a specified color.

drawRoundRect()

Draw a rounded rectangle by left top coordinate and given width and height.

fillRoundRect()

Draw a rounded rectangle by left top coordinate and given width and height. And fill it by a specified color.

drawOval()

Draw a circle or Oval by left top coordinate and given width and height.

fillOval()

Draw a circle or Oval by left top coordinate and given width and height. And fill it by a specified color.

drawPolygon()

Draw a polygon by a collection of coordinate.

setForeground( )

Set the foreground color.

setBackground( )

Set the background color.

Java Mixed Programs Java Examples : Frequency of the character in a paragraph
softetechnologies
Author Details
Arnab De
I have over 16 years of experience working as an IT professional, ranging from teaching at my own institute to being a computer faculty at different leading institute across Kolkata. I also work as a web developer and designer, having worked for renowned companies and brand. Through tutorialathome, I wish to share my years of knowledge with the readers.
Enter New Comment
Comment History
No Comment Found Yet.
Leo Tolstoy
However diffcult life may seem, there is always something you can do, and succeed at. It matters that you don not just give up.
Leo Tolstoy
1983
55.57
Today So Far
Total View (Lakh)
softetechnologies
26/05/2018     42977
01/01/2018     36288
25/06/2018     34740
28/06/2017     34401
02/08/2017     32736
01/08/2017     27246
06/07/2017     27062
15/05/2017     26664
14/07/2017     22275
21/04/2018     20918
softetechnologies