If you want these methods to do something, redefine the method (e.g., paint) in your applet's class definition.
Method | When the method is called, and its purpose |
public void init() | Invoked when the applet is loaded. Typical actions include: initializing instance |
public void start() | Invoked after init(), and whenever the browser Actions include starting anything that would be stopped |
public void paint( Graphics g ) | Invoked after init() completes, and start() has started. Also invoked by repaint(), after it clears the |
public void stop() | Invoked when the applet should stop executing, typically Actions include stopping animations and threads. |
public void destroy() | Invoked when the applet is being removed from memory, All active threads should be terminated, at this point. |
resize( int width, int height)
This method is used to set the size of the applet at execution time (rather than at the time that the applet's web page is defined).
Imagine that we beefed up our RandomlyColoredBoard applet to include a TextField in which the user could specify NUM, where it is a NUM X NUM board. If we want each square to remain 40 pixels, then we can resize the applet (within limits) in response to the integer value of the TextField.
repaint()
This method invokes the method update, which erases all drawing, then invokes the paint method.
This is discussed in detail in Chapter 14 of our text book.