Java Reference
In-Depth Information
NOTE
Overriding paint( ) applies mostly to AWT-based applets. Swing applets use a different
painting mechanism.
Applet Initialization and Termination
It is important to understand the order in which the various methods shown in the skeleton
are executed. When an applet begins, the following methods are called 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.
The init( ) method is the first method to be called. In init( ) your applet will initialize
variables and perform any other startup activities.
The start( ) method is called after init( ) . It is also called to restart an applet after it has
been stopped, such as when the user returns to a previously displayed web page that con-
tains an applet. Thus, start( ) might be called more than once during the life cycle of an
applet.
The paint( ) method is called each time an AWT-based applet's output must be redrawn
and was described earlier.
When the page containing your applet is left, the stop( ) method is called. You will use
stop( ) to suspend any child threads created by the applet and to perform any other activit-
ies required to put the applet in a safe, idle state. Remember, a call to stop( ) does not mean
that the applet should be terminated because it might be restarted with a call to start( ) if
the user returns to the page.
The destroy( ) method is called when the applet is no longer needed. It is used to perform
any shutdown operations required of the applet.
Requesting Repainting
Search WWH ::




Custom Search