Face - y = (PAGE_HEIGHT - height)/2; page.fillOval(x, y,...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
// **************************************************************** // FILE: Face.java // Author: // // Purpose: Draw a smiling face. // // **************************************************************** import javax.swing.JApplet; import java.awt.*; public class Face extends JApplet { //------------------------------------------------------- // Draws a face with eyes (including pupils), ears, a // nose, and a mouth. //------------------------------------------------------- public void paint (Graphics page) { // Declare size constants final int PAGE_WIDTH = 600; final int PAGE_HEIGHT = 400; // Declare variables int x, y, x2, y2; // x and y coordinates for locations of shapes int width, height; // width and height of each shape int startAngle, arcAngle; // start and sweep of arc // Set the background color setBackground (Color.blue); // Draw head page.setColor (Color.yellow); width = 170; height = 200; x = (PAGE_WIDTH - width)/2;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: y = (PAGE_HEIGHT - height)/2; page.fillOval(x, y, width, height); // Draw ears width = 40; height = 70; page.fillOval (x - 25, y + 70, width, height); page.fillOval (x + 155, y + 70, width, height); // Draw eyes with pupils page.setColor (Color.green); width = 30; height = 30; x = x + 40; y = y + 70; page.fillOval(x, y, width, height); page.setColor(Color.black); page.fillOval(x+7, y+7, 16, 16); page.setColor(Color.green); x = x + 60; page.fillOval(x, y, width, height); page.setColor(Color.black); page.fillOval(x+7, y+7, 16, 16); // Draw nose x = x - 15; y = y + 30; x2 = x - 10; y2 = y + 40; page.drawLine(x, y, x2, y2); x = x2 + 10; y = y2 + 5; page.drawLine(x2, y2, x, y); // Draw mouth page.setColor (Color.red); x = x - 40; width = 80; height = 30; startAngle = 180; arcAngle = 180; page.drawArc(x, y, width, height, startAngle, arcAngle); } }...
View Full Document

This note was uploaded on 03/22/2010 for the course CS 202 taught by Professor Fong during the Spring '10 term at SIU Carbondale.

Page1 / 2

Face - y = (PAGE_HEIGHT - height)/2; page.fillOval(x, y,...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online