The Applet Lifecycle
Applet Lifecycle
If you take a look at the earlier sample applets you will notice that unlike applications they have no main method. An applet life cycle is controlled by the init and start methods. The init method is executed when the applet is first loaded into memory, and the start method runs each time the browser visits the page containing the applet. In the HelloApplet example given neither of these methods are defined and so the versions that are called are the default ones supplied by the JApplet class. The default start method has a call to the paint method, which is why those sample applets worked. Note that you generally never call the init or start methods yourself, they are called by the browser at at the appropriate times.
Last modified: Thursday, 24 July 2014, 2:54 PM