64 points
10 5 2

Java’s Applet Skeleton

posted Oct 11 1 min read

An Applet Skeleton

All but the most trivial applets override a set of methods that provides the basic mechanism by which the browser or applet viewer interfaces to the applet and controls its execution. Four of these methods—init( ), start( ), stop( ), and destroy( )—are defined by Applet. Another, paint( ), is defined by the AWT Component class. Default implementations for all of these methods are provided. Applets do not need to override those methods they do not use. However, only very simple applets will not need to define all of them. These five methods can be assembled into the skeleton shown here:

public class AppletSkel extends Applet { 
            // Called first. 
           public void init() {
                           // initialization 
           /* Called second, after init(). Also called whenever the applet is restarted. */ 
           public void start() {
                           // start or resume execution 
           // Called when the applet is stopped.
            public void stop() { 
                          // suspends execution 
           /* Called when applet is terminated. This is the last method executed. */ 
           public void destroy() { 
                          // perform shutdown activities 
           // Called when an applet's window must be restored. 
           public void paint(Graphics g) {
                           // redisplay contents of window 

Although this skeleton does not do anything, it can be compiled and run

It is important to understand the order in which the various methods shown in the skeleton are called. When an applet begins, the AWT calls the following methods, in this sequence:
1. init( )
2. start( )
3. paint( )

When an applet is terminated, the following sequence of method calls takes place:
1. stop( )
2. destroy( )

Let’s look more closely at these methods.

More Posts

Applet Initialization and Termination Takele - Oct 11
Run an applet program in java usmanhashmi - Aug 11
Which of the following tags are no longer valid in html 5? Tushar Shuvro - Apr 24, 2020
Java's Magic : The ByteCode Takele - Sep 23
Java's Object class toString() method DivyaN - Sep 14
student details program in java using applet Mubashir Islam - Oct 28, 2020
Scientific calculator program in java using applet Mubashir Islam - Oct 23, 2020
Which operation could we perform in order to find the number of milliseconds in a year? Alecxe01 - 52 minutes
Please install or use the jre or jdk that contains these missing components. Naymul01 - 1 day
Asking the user for input until they give a valid response java Naymul01 - 1 day