AbdulFathaah

HappyFace

Aug 14th, 2025 (edited)
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.72 KB | None | 0 0
  1. import java.applet.Applet;
  2. import java.awt.*;
  3.  
  4. /*
  5. <applet code="HappyFace" width="300" height="300">
  6. </applet>
  7. */
  8.  
  9. public class HappyFace extends Applet {
  10.     public void paint(Graphics g) {
  11.         // Set the background color
  12.         setBackground(Color.white);
  13.  
  14.         // Face (yellow circle)
  15.         g.setColor(Color.yellow);
  16.         g.fillOval(50, 50, 200, 200); // x, y, width, height
  17.  
  18.         // Eyes (black ovals)
  19.         g.setColor(Color.black);
  20.         g.fillOval(90, 100, 20, 30); // Left eye
  21.         g.fillOval(190, 100, 20, 30); // Right eye
  22.  
  23.         // Smile (red arc)
  24.         g.setColor(Color.red);
  25.         g.drawArc(100, 120, 100, 80, 0, -180); // x, y, width, height, startAngle, arcAngle
  26.     }
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment