// Fig. 11.4: CustomCanvas.java // A customized Canvas class. import java.awt.*; public class CustomCanvas extends Canvas { public final static int CIRCLE = 1, SQUARE = 2; private int shape; public void paint( Graphics g ) { if ( shape == CIRCLE ) g.fillOval( 50, 10, 60, 60 ); else if ( shape == SQUARE ) g.fillRect( 50, 10, 60, 60 ); } public void draw( int s ) { shape = s; repaint(); } }