I am taking a beginner course and just started today to read about
applets and graphics. This is not homework, I am creating this for practice as I read the chapter. I followed an example of an applet to draw a rectangle:
import java.applet.Applet;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
/**
An applet that draws two rectangles.
*/
public class RectangleApplet extends Applet
{
public void paint(Graphics g)
{
Graphics2D g2 = (Graphics2D)g;
Rectangle cerealBox = new Rectangle(5, 10, 20, 30);
g2.draw(cerealBox);
}
}
and created one to draw an Ellipse:
import java.applet.Applet;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Ellipse2D;
/**
An applet that draws an ellipse.
*/
public class Ellipse2D.DoubleApplet extends Applet
{
public void paint(Graphics g)
{
Graphics2D g2 = (Graphics2D)g;
Ellipse2D.Double easterEgg = new Ellipse2D.Double(5, 10, 15, 20);
g2.draw(easterEgg);
}
}
but it doesn't compile. I imagine the error is very simple! But I am totally new to this so I apologize for such a basic question. Is my class worng? Thanks for any help.