Applet Life Cycle Example

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

Visit Java Example Forums to request Java examples or ask Java questions!
OR
Try out our new Java Search Engine




Suggested Reading

Oracle Magazine
Contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more.
Cost: FREE

View/Subscribe
NASA Tech Briefs
Features exclusive reports of innovations developed by NASA and its industry partners/contractors that can be applied to develop new/improved products and solve engineering or manufacturing problems.
Cost: FREE

View/Subscribe
FierceBiotech IT
Is a free, easy to read weekly email service that brings must read biotech IT news to senior biotech, pharma, and IT executives.
Cost: FREE

View/Subscribe
Simply SQL
Simply SQL is a practical step-by-step guide to writing SQL.
Cost: FREE

View/Subscribe
Simply JavaScript
Packed with full-color examples, Simply JavaScript is all you need to start programming in JavaScript the right way.
Cost: FREE

View/Subscribe
PCMag.com's What's New Now
Lance Ulanoff, Editor in Chief of the PC Magazine Network, brings you this twice-weekly roundup of the latest top tech stories, the best new product reviews, plus special offers from Ziff Davis and its partners.
Cost: FREE

View/Subscribe

Could not find what you are looking for? Search Java Examples




Feel Tired? Read Jokes & Inspirational Stories, Play Games!