public class DrawFaceSwing extends JFrame
1: import java.awt.Graphics;
2: import javax.swing.JFrame;
4: /**
5: * A program to draw a happy face.
6: *
7: * @author Mark Young (A00000000)
8: */
9: public class DrawFaceSwing extends JFrame {
11: private static final int WIDTH = 400;
12: private static final int HEIGHT = 300;
14: /**
15: * Create the window to draw on.
16: */
17: public DrawFaceSwing() {
18: super("Happy Face Using Swing");
19: this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
20: setSize(WIDTH, HEIGHT);
21: }
22:
23: /**
24: * Draw a happy face in the window.
25: *
26: * @param g the "paint-brush" for this window.
27: */
28: @Override
29: public void paint(Graphics g) {
30: g.drawOval(100, 50, 200, 200); // face outline
31: g.fillOval(155, 100, 10, 20); // one eye
32: g.fillOval(230, 100, 10, 20); // other eye
33: g.drawArc(150, 160, 100, 50, 0, -180); // smile
34: }
36: /**
37: * @param args the command line arguments -- ignored
38: */
39: public static void main(String[] args) {
40: DrawFaceSwing win = new DrawFaceSwing();
41: win.setVisible(true);
42: }
44: }