What do you suppose happens if you forget the match to a
<head>
tag?
Answer:
The rest of the file is regarded as part of the head, and will not show up in the browser as you expect.
Drawing Circles
The previous applets in this chapter have only printed text. Here is an applet that draws a circle.
import javax.swing.JApplet;
import java.awt.*;
// assume that the drawing area is 150 by 150
public class JustOneCircle extends JApplet
{
final int radius = 25;
public void paint ( Graphics gr )
{
setBackground( Color.lightGray );
gr.drawOval( (150/2 - radius), (150/2 - radius), radius*2, radius*2 );
}
}
Here is what the applet paints with your Web browser:
Embedded Java applet removed: modern browsers do not support Java applets. The surrounding source code is retained for historical study.
QUESTION 13:
What is the name of the method that drew the circle?