Java Blog

 
 
 
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 sets up a String variable containing a paragraph of text of your choice. Extract the words from the text and sort them into alphabetical order

  2. File handling program to copy bytes from one file to another

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

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

  5. Develop a game application in CORBA for which the player will guess a number between 1 to 100, which will be compared to the random number generated b

  6. GUI application in java, which enter the details of a student and on the submit display the details of the student

  7. Program to reverse the number eg given no : - 12345, output want :- 54321

  8. Write a class whose objects holds a current value and have a method to add that value, printing the new value

  9. Program to calculate the frequency for different values of C starting from 0.01 to 0.1 in steps of 0.01

  10. RMI program of count server and client

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

  12. Program of an applet to illustrate BarChart

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

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

  15. Program to find a factorial of a given number

  16. An applet program of passing parameters

  17. Program to find the number of and sum of all integers greater than 100 and less than 200 that are divisible by 7

  18. Program to show an example of modifying String objects

  19. Program to show the use of some Math Methods

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

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