October 27th, 2014
Classwork:
Use a JFrame to create an application, YI_ManyShapes.java and YI_ManyShapesJFrame.java that draws rectangles, ellipses and lines. Use different colors and fill.
Here is a good source for your application:

Here is a simple example:
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import javax.swing.JComponent;
/**
* Write a description of class RectangleObject here.
*/
public class RectangleObject extends JComponent
{
public void paintComponent(Graphics g)
{
Graphics2D g2 = (Graphics2D) g;
// Construct a rectangle object
Rectangle box = new Rectangle(5, 10, 20, 30);
// draw the rectangle
g2.draw(box);
}
}
The JFrame class:
import javax.swing.JFrame;
/**
* Draw an empty frame using JFrame.
*
*/
public class RectangleJFrame
{
public static void main(String[] args)
{
JFrame frame = new JFrame();
frame.setSize(300,400);
frame.setTitle("A Rectanlge Object in a JFrame");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
RectangleObject aRectangle = new RectangleObject();
frame.add(aRectangle);
frame.setVisible(true);
}
}
Homework:
Write an application, YI_HappyFace.java using what you learned from Manyshapes to draw a happy face. Make sure to include the JFrame class also.
