What are the methods that control an applet’s on-screen appearance? I.e. update and paint. - The paint() method is called in situations the applet window being overwritten by another window or uncovered or the applet window being resized.
- The paint() is also called when the applet begins execution. The paint() method has one parameter of type Graphics which is needed to know the location where the applet is supposed to paint its output.
- The update() is called when a portion of its window be redrawn. It is defined by the AWT.
- However, the update() first fills an applet with the default background colour and then calls paint() due to which an instance of the default color appears each time update is called.
- Thus update() method should be overridden to avoid this situation.
|