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. Program to show an example of Calling a Base Class Method from a Derived Class

  2. Program to show an example of creating Character Arrays from String objects

  3. Program to show an example of using initialization block to initialize the data members of a class

  4. Corba program of Count Client Applet, IDL,Server, Client

  5. Do the following for the Array Insert the element in the array,delete an element from the array,search for a particular element Create multiple thread

  6. Game application in CORBA for which player will guess a number between 1 to 100, which will be compared to the random number generated by the class

  7. Program to show the use of If Statement

  8. Program to show the use of Conditional (Ternary) Operator

  9. Program to show an example of creating a String object from a StringBuffer Object

  10. Program to read rollno, marks of sub1,sub2 and sub3 and on basis of that display result

  11. An applet program of passing parameters

  12. Program to show an example of using user-defined package in a program

  13. Program to show an example of using constructors in a class to initialize its data members

  14. Program to show insertion of StringBuffer, String objects and other Basic Data Types into a StringBuffer object

  15. An applet program of linear sort

  16. Program to compute the sum of the digits of a given integer number. eg: I/o=4 then O/p=4+3+2+1=10

  17. Socket program of HTTP Server

  18. Develop a CORBA based application for addition of two complex numbers and displaying the result on client side

  19. Program to show the use of Increment and Decrement Operators

  20. Program to show an example of modifying String objects

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