Explain the methods that control a Applet's on-screen appearance, update and paint. To refresh a page in an applet window without flashing, the update() method is to be overridden. It clears the background of the component, before invoking paint().
paint(): Every applet must implement the paint() method. A Graphics object is passed to the paint() method. drawstring() is the method used to write the contents on the applet’s window. The other methods of Graphics class are setColor(),drawRect(),setBackground() etc. All these methods are to be implemented in the paint() method.
Methods to control applet's appearance, update and paint
- The Applet class inherits a paint method from its parent Container class.
- The paint method is called when the applet is loaded, scrolled, etc.
- The update method is called in response to repaint and calls paint in turn.