ProgramHierarchy - GRect gpRect = new...

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

View Full Document Right Arrow Icon
/* * File: * Name: * Section Leader: * --------------------------- * This file is the starter file for the ProgramHierarchy problem. */ import*; import acm.program.*; import java.awt.*; i public class ProgramHierarchy extends GraphicsProgram { p /** Width of each box in pixels */ private static final int BOX_WIDTH = 150; p /** Width of each box in pixels */ private static final int BOX_HEIGHT = 40; p public void run() { p int x=getWidth()/2; int y=getHeight()/2; GRect progRect = new GRect(x-(BOX_WIDTH/2),y- (3*BOX_HEIGHT/2),BOX_WIDTH,BOX_HEIGHT); add(progRect); GLabel progLabel = new GLabel("Program"); progLabel.setLocation(x-(progLabel.getWidth()/2),y-(BOX_HEIGHT- progLabel.getAscent()/2)); add(progLabel); GLine line1 = new GLine(x,y-(BOX_HEIGHT/2),x,y+(BOX_HEIGHT/2)); add(line1); GRect cpRect = new GRect(x-(BOX_WIDTH/2),y+ (BOX_HEIGHT/2),BOX_WIDTH,BOX_HEIGHT); add(cpRect);
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: GRect gpRect = new GRect(x-(3*BOX_WIDTH/2)-20,y+ (BOX_HEIGHT/2),BOX_WIDTH,BOX_HEIGHT); add(gpRect); GRect dpRect = new GRect(x+(BOX_WIDTH/2)+20,y+ (BOX_HEIGHT/2),BOX_WIDTH,BOX_HEIGHT); add(dpRect); GLine line2 = new GLine(x,y-(BOX_HEIGHT/2),x-(BOX_WIDTH)-20,y+ (BOX_HEIGHT/2)); add(line2); GLine line3 = new GLine(x,y-(BOX_HEIGHT/2),x+(BOX_WIDTH)+20,y+ (BOX_HEIGHT/2)); add(line3); GLabel cpLabel = new GLabel("ConsoleProgram"); cpLabel.setLocation(x-(cpLabel.getWidth()/2),y+BOX_HEIGHT+cpLabel.getAscent()/2); add(cpLabel); GLabel gpLabel = new GLabel("GraphicsProgram"); gpLabel.setLocation(x-(BOX_WIDTH)-20-(gpLabel.getWidth()/2),y+BOX_HEIGHT+gpLabel.getAscent()/2); add(gpLabel); GLabel dpLabel = new GLabel("DialogProgram"); dpLabel.setLocation(x+(BOX_WIDTH)+20-(dpLabel.getWidth()/2),y+BOX_HEIGHT+dpLabel.getAscent()/2); add(dpLabel); } }...
View Full Document

This note was uploaded on 10/25/2010 for the course CS 106A at Stanford.

Page1 / 2

ProgramHierarchy - GRect gpRect = new...

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