Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.applet.Applet;
- import java.awt.*;
- /*
- <applet code="HappyFace" width="300" height="300">
- </applet>
- */
- public class HappyFace extends Applet {
- public void paint(Graphics g) {
- // Set the background color
- setBackground(Color.white);
- // Face (yellow circle)
- g.setColor(Color.yellow);
- g.fillOval(50, 50, 200, 200); // x, y, width, height
- // Eyes (black ovals)
- g.setColor(Color.black);
- g.fillOval(90, 100, 20, 30); // Left eye
- g.fillOval(190, 100, 20, 30); // Right eye
- // Smile (red arc)
- g.setColor(Color.red);
- g.drawArc(100, 120, 100, 80, 0, -180); // x, y, width, height, startAngle, arcAngle
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment