×
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
4981    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.
Albert Einstein
Few are those who see with their own eyes and feel with their own hearts.
Albert Einstein
1410
59.47
Today So Far
Total View (Lakh)
softetechnologies
26/05/2018     44336
01/01/2018     36726
25/06/2018     36300
28/06/2017     34765
02/08/2017     33320
01/08/2017     27720
06/07/2017     27482
15/05/2017     27080
14/07/2017     22796
11/09/2018     21441
softetechnologies