// Helene Martin, CSE 142 // Demonstrates basics of using graphics import java.awt.*; // Abstract (Another) Windowing Toolkit public class GraphicsDemo { public static void main(String[] args) { DrawingPanel p = new DrawingPanel(300, 500); Graphics g = p.getGraphics(); g.setColor(Color.GREEN); g.fillOval(10, 10, 90, 90); g.setColor(Color.BLUE); g.drawOval(10, 10, 90, 90); //x1 y1 x2 y2 g.drawLine(10, 10, 100, 100); //x1 y1 w h g.drawRect(10, 10, 90, 90); // using loops that start at 0 makes coordinate // math easier for (int i = 0; i < 3; i++) { g.drawOval(200 + 20 * i, 10 + 20 * i, 20, 20); } // we can use for loop figures to get expressions //g.drawOval(200, 10, 20, 20); //g.drawOval(220, 30, 20, 20); //g.drawOval(240, 50, 20, 20); } }