Coords - x = PAGE_WIDTH/2 - 75; y = PAGE_HEIGHT/2 - 50;...

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

View Full Document Right Arrow Icon
// **************************************************************** // Coords.java // // Draw rectangles to illustrate the Java coordinate system // // **************************************************************** import javax.swing.JApplet; import java.awt.*; public class Coords extends JApplet { public void paint (Graphics page) { // Declare size constants final int MAX_SIZE = 300; final int PAGE_WIDTH = 600; final int PAGE_HEIGHT = 400; // Declare variables int x, y; // x and y coordinates of upper left-corner of each shape int width, height; // width and height of each shape // Set the background color setBackground (Color.yellow); // Set the color for the next shape to be drawn page.setColor (Color.blue); // Assign the corner point and width and height of the middle rectangle
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: x = PAGE_WIDTH/2 - 75; y = PAGE_HEIGHT/2 - 50; width = 150; height = 100; page.fillRect(x, y, width, height); // Assign color and corner point for the upper left rectangle page.setColor (Color.red); x = 0; y = 0; page.fillRect(x, y, width, height); // Assign color and corner point for the upper right rectangle page.setColor (Color.black); x = PAGE_WIDTH - 150; y = 0; page.fillRect(x, y, width, height); // Assign color and corner point for the lower left rectangle page.setColor (Color.green); x = 0; y = PAGE_HEIGHT - 100; page.fillRect(x, y, width, height); // Assign color and corner point for the lower right rectangle page.setColor (Color.magenta); x = PAGE_WIDTH - 150; y = PAGE_HEIGHT - 100; page.fillRect(x, y, width, height); } }...
View Full Document

Page1 / 2

Coords - x = PAGE_WIDTH/2 - 75; y = PAGE_HEIGHT/2 - 50;...

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