@@ -0,0 +1,2702 @@
+import java.awt.Color;%0Aimport java.awt.Dimension;%0Aimport java.awt.Graphics;%0Aimport java.awt.Graphics2D;%0Aimport java.awt.RenderingHints;%0Aimport java.awt.event.WindowAdapter;%0Aimport java.awt.event.WindowEvent;%0A%0Aimport javax.swing.JFrame;%0Aimport javax.swing.JPanel;%0A%0A/** Displays a window and delegates drawing to DrawGraphics. */%0Apublic class SimpleDraw extends JPanel implements Runnable %7B    %0A    private static final long serialVersionUID = -7469734580960165754L;%0A    private boolean animate = true;%0A    private final int FRAME_DELAY = 50; // 50 ms = 20 FPS%0A    public static final int WIDTH = 300;%0A    public static final int HEIGHT = 300;%0A    private DrawGraphics draw;%0A%0A    %0A    public SimpleDraw(DrawGraphics drawer) %7B%0A        this.draw = drawer;%0A    %7D%0A%0A    /** Paint callback from Swing. Draw graphics using g. */%0A    public void paintComponent(Graphics g) %7B%0A        super.paintComponent(g);%0A%0A        // Enable anti-aliasing for better looking graphics %0A        Graphics2D g2 = (Graphics2D) g;%0A        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);%0A        draw.draw(g2);%0A    %7D%0A%0A    /** Enables periodic repaint calls. */%0A    public synchronized void start() %7B%0A        animate = true;%0A    %7D%0A%0A    /** Pauses animation. */%0A    public synchronized void stop() %7B%0A        animate = false;%0A    %7D%0A%0A    private synchronized boolean animationEnabled() %7B%0A        return animate;%0A    %7D%0A%0A    public void run() %7B%0A        while (true) %7B%0A            if (animationEnabled()) %7B%0A                repaint();%0A            %7D%0A%0A            try %7B%0A                Thread.sleep(FRAME_DELAY);%0A            %7D catch (InterruptedException e) %7B%0A                throw new RuntimeException(e);%0A            %7D%0A        %7D%0A    %7D%0A%0A    public static void main(String args%5B%5D) %7B%0A        final SimpleDraw content = new SimpleDraw(new DrawGraphics());%0A%0A        JFrame frame = new JFrame(%22Graphics!%22);%0A       %0A        Color bgColor = Color.white;%0A        frame.setBackground(bgColor);%0A        content.setBackground(bgColor);%0A//        content.setSize(WIDTH, HEIGHT);%0A//        content.setMinimumSize(new Dimension(WIDTH, HEIGHT));%0A        content.setPreferredSize(new Dimension(WIDTH, HEIGHT));%0A//        frame.setSize(WIDTH, HEIGHT);%0A        frame.setContentPane(content);%0A        frame.setResizable(false);%0A        frame.pack();%0A        frame.addWindowListener(new WindowAdapter() %7B%0A            public void windowClosing(WindowEvent e) %7B System.exit(0); %7D%0A            public void windowDeiconified(WindowEvent e) %7B content.start(); %7D%0A            public void windowIconified(WindowEvent e) %7B content.stop(); %7D%0A        %7D);%0A%0A        new Thread(content).start();%0A%0A        frame.setVisible(true);%0A    %7D%0A%7D%0A

Create SimpleDraw.java