// Helene Martin, CSE 142 // Demonstrates basic 2D graphics with DrawingPanel. import java.awt.*; // Advanced (Another) Windowing Toolkit (for Graphics, Color) public class GraphicsDemo { public static void main(String[] args) { DrawingPanel p = new DrawingPanel(400, 300); // g is the "paintbrush" Graphics g = p.getGraphics(); //x1 y1 x2 y2 g.drawLine(0, 0, 40, 40); //x y w h g.drawOval(40, 40, 40, 80); g.drawRect(40, 40, 40, 80); g.setColor(Color.PINK); // dipped paintbrush in pink g.fillRect(100, 100, 40, 40); g.drawLine(140, 140, 180, 150); // drawing an outline g.setColor(Color.BLACK); g.drawRect(100, 100, 40, 40); } }