public class DrawSmiley extends JPanel
1: // Fig. 6.16: DrawSmiley.java
2: // Demonstrates filled shapes.
3: import java.awt.Color;
4: import java.awt.Graphics;
5: import javax.swing.JPanel;
7: public class DrawSmiley extends JPanel
8: {
9: public void paintComponent( Graphics g )
10: {
11: super.paintComponent( g );
13: // draw the face
14: g.setColor( Color.YELLOW );
15: g.fillOval( 10, 10, 200, 200 );
16:
17: // draw the eyes
18: g.setColor( Color.BLACK );
19: g.fillOval( 55, 65, 30, 30 );
20: g.fillOval( 135, 65, 30, 30 );
21:
22: // draw the mouth
23: g.fillOval( 50, 110, 120, 60 );
24:
25: // "touch up" the mouth into a smile
26: g.setColor( Color.YELLOW );
27: g.fillRect( 50, 110, 120, 30 );
28: g.fillOval( 50, 120, 120, 40 );
29: } // end method paintComponent
30: } // end class DrawSmiley
33: /**************************************************************************
34: * (C) Copyright 1992-2005 by Deitel & Associates, Inc. and *
35: * Pearson Education, Inc. All Rights Reserved. *
36: * *
37: * DISCLAIMER: The authors and publisher of this book have used their *
38: * best efforts in preparing the book. These efforts include the *
39: * development, research, and testing of the theories and programs *
40: * to determine their effectiveness. The authors and publisher make *
41: * no warranty of any kind, expressed or implied, with regard to these *
42: * programs or to the documentation contained in these books. The authors *
43: * and publisher shall not be liable in any event for incidental or *
44: * consequential damages in connection with, or arising out of, the *
45: * furnishing, performance, or use of these programs. *
46: *************************************************************************/