import javabook.*; import java.awt.*; /** * DrawingLab1 * Inspired by a lab from Jeff Ondich * @author Dave Musicant * @version 1.0 10/2/01 * * This class is used to open a graphics window * and draw a red circle in the center. * * Try doing these things: * 0. Compile this class. * 1. Create another class called DrawingLab1Main that just contains * a main method. * 2. In that main method, create a DrawingLab1 object and * call the method "start". * 3. Run the method "main" in DrawingLab1Main. * 4. Read all the Java code to find out how it works. * 5. Modify the code so that the circle appears in a different * location on the screen. * 6. Make the circle green. */ class DrawingLab1 { // Data values final int centerX = 200; final int centerY = 100; final int radius = 50; DrawingBoard drawingBoard; // DrawingBoard is a special type of MainWindow MessageBox messageBox; /** * Constructor */ public DrawingLab1() { // Create objects for the DrawingBoard and other input / output drawingBoard = new DrawingBoard("Time to do some drawing"); messageBox = new MessageBox(drawingBoard); // Make the drawingBoard visible and bring to front drawingBoard.setVisible(true); drawingBoard.toFront(); } /** * Method that does the actual drawing. */ public void start() { drawingBoard.setColor(Color.red); drawingBoard.drawCircle(centerX,centerY,radius); messageBox.show("I drew a circle!"); } }