Assignment 4: Graphics and Drawing - Due Monday, July 7th
This assignment will be the first that we used Java's graphic abilities.
You need to create a GUI. This GUI must:
- Display an Image (you can choose one.. about 50x50 pixels
will probably be a good size). This should be more or less centered (off by a few pixels
ok - noticeably off to one side isn't).
- Have two JButtons. One of the JButtons will change the background to a random
color. The other will should draw a shape (a circle OR a rectangle, randomly chosen)
around the image. This should also be centered.
- Extra Credit 10%: Add another shape other than one of the predefined Java2D ones (a triangle is fine)
- Extra Credit 10%: Make all your code centering itself be DYNAMIC. If the program is run, and the user maximizes the screen, everything should re-center itself (Layout Managers help with this!)
So, it should look like this when it is just opened

and then like this when a each button is pressed once
Some hints on doing this.
- General hint: Think about what you're going to do before you try
to start writing code. I did this in under 100 lines of code, so if you're code
is blowing up, you might want to re-think what we're doing.
- You're going to have to overload paintComponent() method to get stuff to draw.
To do this in a flexible way, I would extend the JPanel class to make your own
JPanel, then add this to the main frame. This is how your book does it, look there
for examples.
- Look at the Graphics2D Ellipse2D.Double and Rectangle2D.Double classes for the shapes.
import java.awt.geom to use them