Java Tutorial

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

public class LifeCycle extends Applet
{
      private static int initcall, startcall, paintcall, stopcall, destroycall;

      public void init()
      {
          setBackground(Color.cyan);
          setForeground(Color.red);
          initcall=initcall+1;
      }

      public void start()
      {
           startcall=startcall+1;
      }

      public void paint(Graphics g)
      {
              paintcall=paintcall+1;
              g.drawString(\"init Method is called for  : \"+initcall,0,14);
              g.drawString(\"start Method is called for  : \"+startcall,0,30);
              g.drawString(\"paint Method is called for : \"+paintcall,0,46);
              g.drawString(\"stop Method is called for : \"+stopcall,0,62);
              g.drawString(\"destroy Method is called for : \"+destroycall,0,78);
              showStatus(\"Demo of Applet Life Cycle\");
     }

     public void stop()
     {
            stopcall=stopcall+1;
     }

     public void destroy()
     {
            destroycall=destroycall+1;
     }
}

    Related Post:
  1. Encrypt the text that you want to send on the client side. The server side decrypts it after receiving. Append server time after each word in the sent

  2. Program to declare and initialize Boolean variables and print them on the Standard Output Device

  3. Program to show an example of searching Strings for subStrings

  4. Program to compare Strings by compring successive corresponding characters, starting with the first character in each String

  5. Program to show the use of some Math Methods

  6. Program to delete mth element from an input string

  7. Program, which creates a three thread. One thread display the numbers from 1 to 5, second thread display the square root of that number etc

  8. Program to show an example of using Abstract Class and Abstract Method

  9. Program to declare, initialize and print a String object

  10. Program to declare, initialize and print an array of characters

  11. Program to show the use of For Loop

  12. Program to change characters in a StringBuffer objects and to reverse its contents

  13. An applet program to display Horizontal Color Bar

  14. Program of Floyds Triangle

  15. Program to show the use of Logical AND Operator (&) in If Statements

  16. Program of UDP datagram

  17. Word list program that reads a text file and makes an alphabetical list of all the words in that file. The list of words is output to another file

  18. Program to read the ballots and count the votes cast for each candidate using an array variable count

  19. Program to read input from the Standard Input Device

  20. RMI based application for login validation based on data saved in text file stored on the server and will display appropriate message to the client..

 
 
Didn't find what you were looking for? Find more on Simple Applet which will show life cycle of an Applet