answersLogoWhite

0


Best Answer
  1. /*
  2. Applet Life Cycle Example
  3. This java example explains the life cycle of Java applet.
  4. */
  5. import java.applet.Applet;
  6. import java.awt.Graphics;
  7. /*
  8. *
  9. * Applet can either run by browser or appletviewer application.
  10. * Define tag within comments as given below to speed up
  11. * the testing.
  12. */
  13. /*
  14. */
  15. public class AppletLifeCycleExample extends Applet{
  16. /*
  17. * init method is called first.
  18. * It is used to initialize variables and called only once.
  19. */
  20. public void init() {
  21. super.init();
  22. }
  23. /*
  24. * start method is the second method to be called. start method is
  25. * called every time the applet has been stopped.
  26. */
  27. public void start() {
  28. super.start();
  29. }
  30. /*
  31. * stop method is called when the the user navigates away from
  32. * html page containing the applet.
  33. */
  34. public void stop() {
  35. super.stop();
  36. }
  37. /* paint method is called every time applet has to redraw its
  38. * output.
  39. */
  40. public void paint(Graphics g) {
  41. super.paint(g);
  42. }
  43. /*
  44. * destroy method is called when browser completely removes
  45. * the applet from memeory. It should free any resources initialized
  46. * during the init method.
  47. */
  48. public void destroy() {
  49. super.destroy();
  50. }
  51. }
  52. User Avatar

    Wiki User

    11y ago
    This answer is:
    User Avatar

    Add your answer:

    Earn +20 pts
    Q: Write a program to show the applet life cycle?
    Write your answer...
    Submit
    Still have questions?
    magnify glass
    imp
    Related questions

    Lifecycle diagram of applet in java?

    IntroductionIn this Section you will learn about the lifecycle of an applet and different methods of an applet. Applet runs in the browser and its lifecycle method are called by JVM when it is loaded and destroyed. Here are the lifecycle methods of an Applet:init(): This method is called to initialized an appletstart(): This method is called after the initialization of the applet.stop(): This method can be called multiple times in the life cycle of an Applet.destroy(): This method is called only once in the life cycle of the applet when applet is destroyed.init () method: The life cycle of an applet is begin on that time when the applet is first loaded into the browser and called the init() method. The init() method is called only one time in the life cycle on an applet. The init() method is basically called to read the PARAM tag in the html file. The init () method retrieve the passed parameter through the PARAM tag of html file using get Parameter() method All the initialization such as initialization of variables and the objects like image, sound file are loaded in the init () method .After the initialization of the init() method user can interact with the Applet and mostly applet contains the init() method.Start () method: The start method of an applet is called after the initialization method init(). This method may be called multiples time when the Applet needs to be started or restarted. For Example if the user wants to return to the Applet, in this situation the start Method() of an Applet will be called by the web browser and the user will be back on the applet. In the start method user can interact within the applet.Stop () method: The stop() method can be called multiple times in the life cycle of applet like the start () method. Or should be called at least one time. There is only miner difference between the start() method and stop () method. For example the stop() method is called by the web browser on that time When the user leaves one applet to go another applet and the start() method is called on that time when the user wants to go back into the first program or Applet.destroy() method: The destroy() method is called only one time in the life cycle of Applet like init() method. This method is called only on that time when the browser needs to Shut down.


    Why main function is not used in applet programs?

    Because an applet runs in a browser, and in this context the one in charge of the launch and execution of the applet is the Java Plug-in software in the browser. This plugin controls the applet life cycle through methods in our applet. These methods are init, start, stop and destroy. In this case the methods that the plugin search to begin the execution of the applet are init (to initialize itself) and start (to start the execution of the task in the applet).


    Can you write a sentence on the word cycle?

    Life would not exist without the water cycle.


    What is the final stage of the program development life cycle?

    the 7th step maintain the program/system


    What was john laing's program for life?

    to write aims for his life....you got a essay to write about john laing init lol


    What is difference between classes and modules?

    i think module life cycle manage program..


    When does the largest distribution of software cost occur in the program's life cycle?

    Early


    How do you write a story about butterflies and the story is nonfiction?

    To write a nonfiction story about butterflies, conduct research to gather facts and information about them. Focus on their life cycle, habitat, behavior, and importance to the ecosystem. Incorporate real-life experiences or observations to make the story engaging and authentic.


    Where in the system's life cycle should a program manager consider esoh requirements?

    All phases.


    Where in the system's life-cycle should a Program Manager consider ESOH requirements?

    A Program Manager should consider ESOH (Environment, Safety, and Occupational Health) requirements throughout the entire system's life cycle, from initial planning and design phases to development, testing, deployment, operation, and disposal. Integration of ESOH considerations early on can help identify potential risks and ensure compliance with regulations and standards to minimize negative impacts on the environment, safety, and health.


    Which phase of the system development life cycle explores the problem in depth and develops program specifications?

    analysis


    What Steps involved in computer program development life cycle?

    1.Review the input, processing, output, and storage requirements. 2.Develop the logic for the program 3.Write the program using a programming language. 4.Test and debug the program. 5.Complete the program documentation.