If your applet will deal with graphics directly, canvases are a good idea. Once you start filling up a window with lots of interface elements and multiple panels, it is best not to draw directly onto the window surface any more. This is because your drawing will interfere with the buttons. Instead you add a canvas to the window.
A canvas is simply a rectangular area in which you can draw. (In contrast, a panel is a rectangular area into which you can place user interface components.) Making a canvas is a bit more complex than using a panel because you need to specify how to draw on the canvas. This means you must derive a new class from Canvas and then override the paint method in your extended class.
Canvases provide a basic component that catches expose events, mouse events, and other events. While the basic canvas does nothing with these events, you can extend canvas to create your own functioning canvases.
By creating a subclass of Canvas, we can override the usual event handling methods in addition to the paint methods.
Canvases simplify the production of applets requiring unique functionality for several distinct areas.
Below we override the paint() method and provide mouse access to the canvas
Here it is running