/** FaceWithHat.java **/ import java.awt.* ; import java.applet.Applet ; /** FaceWithHat: * The applet class for CIT CS Workshop for Girls * * @author CJCSchauble * @version June 2001 **/ public class FaceWithHat extends Applet { /** constant height of area in pixels needed for applet figure **/ public final int FIGUREHEIGHT = 235; /** constant width of area in pixels needed for applet figure **/ public final int FIGUREWIDTH = 205; /** constant definitions of red, green, and blue components * for a dark pink **/ Color PINK4 = new Color ( 255, 128, 128 ) ; /** constant definitions of red, green, and blue components * for a medium green **/ Color GREEN2 = new Color ( 0, 208, 0 ) ; /** constant definitions of red, green, and blue components * for a light blue **/ Color LTBLUE = new Color ( 35, 206, 255 ) ; /** The method that draws the face **/ public void paint (Graphics theFace) { // background for figure theFace.setColor ( Color.white ) ; theFace.fillRect ( 0, 0, FIGUREWIDTH, FIGUREHEIGHT ) ; // outline of face theFace.setColor ( Color.black ) ; theFace.drawOval ( 20, 54, 166, 166 ) ; // mouth theFace.setColor ( PINK4 ) ; theFace.fillOval ( 91, 160, 24, 24 ) ; // two eyes theFace.setColor ( LTBLUE ) ; theFace.fillOval ( 66, 108, 16, 16 ) ; theFace.setColor ( LTBLUE ) ; theFace.fillOval ( 124, 108, 16, 16 ) ; // hat theFace.setColor ( GREEN2 ) ; theFace.fillRect ( 20, 35, 166, 42 ) ; theFace.setColor ( GREEN2 ) ; theFace.fillRect ( 62, 15, 83, 22 ) ; // nose theFace.setColor ( Color.black ) ; theFace.drawLine ( 103, 125, 103, 151) ; theFace.fillOval ( 96, 150, 3, 3 ) ; theFace.fillOval ( 107, 150, 3, 3 ) ; // eyebrows theFace.setColor ( Color.black ) ; theFace.drawLine ( 74, 100, 84, 104) ; theFace.drawLine ( 74, 100, 59, 110) ; theFace.drawLine ( 132, 100, 122, 104) ; theFace.drawLine ( 132, 100, 147, 110) ; } }