/*This application draws a large red circle. If the mouse button is pressed within the circle it is colored red. Then the screen clears. */ import element.*; import structure.*; import java.awt.Color; public class IfMouse { public static void main(String args[]) { DrawingWindow d = new DrawingWindow(); // we need a drawing window Pt center = new Pt(100,100); // to be the center of a circle Circle c = new Circle(center,50); // here the circle is created Pt p ; // a point for use with mouse c.drawOn(d); // we first have to draw the circle on the window d.awaitMousePress(); // wait for the mouse button to be pressed d.moveTo(d.getMouse()); p=d.getMouse(); // p is where the button was pressed if(c.contains(p)) // decide whether to color the circle { d.setForeground(Color.red); // choose red for a color d.fill(c); // color the circle } while(d.mousePressed()) {;} // don't do anything so long as the mouse is pressed c.clearOn(d); // clear the screen } }