The two classes given here combined to display a drawing on a panel on your screen.
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JComponent;

public class DrawnComponent extends JComponent
{
public void paintComponent(Graphics g)
{
g.setColor(Color.BLUE);
g.drawRect(60, 10, 50, 10);
g.setColor(Color.RED);
g.fillRect(100, 130, 30, 70);
g.setColor(Color.GRAY);
g.drawOval(60, 60, 100, 50);
g.setColor(Color.YELLOW);
g.fillOval(30, 80, 10, 15);
g.setColor(Color.BLACK);
g.drawLine(10, 15, 150, 180);
g.setColor(Color.GREEN);
g.drawString("APCS", 140, 30);
}
}

import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JFrame;
import javax.swing.JComponent;

public class GraphicsTester
{
public static void main(String[] args)
{
JFrame j = new JFrame();
j.setSize(200, 300);
j.setTitle("Collage of Shapes");
j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JComponent drawing = new DrawnComponent();
j.add(drawing);
j.setVisible(true); //shows panel with drawing
}
}
1. Type in the sample programs from the previous page and see what happens. Then, experiment with the numbers in each of the statements until you are confident you know how each affects the picture. You do not need to turn in this program.
2. Adapt the code from the sample programs to draw the flags of Benin, Laos, and a third country of your choice (I choose Jamaica, St. Kitts, or Brazil).
3. Adapt the code from the sample programs to draw a corporate logo of your choice.

Extra Credit: Write a program that draws the Olympic flag.