fork download
  1. import javax.swing.*;
  2. import java.awt.*;
  3.  
  4. public class Smiley extends JPanel {
  5.  
  6. @Override
  7. protected void paintComponent(Graphics g) {
  8. super.paintComponent(g);
  9.  
  10. // Face
  11. g.setColor(Color.YELLOW);
  12. g.fillOval(50, 50, 200, 200);
  13.  
  14. // Face outline
  15. g.setColor(Color.BLACK);
  16. g.drawOval(50, 50, 200, 200);
  17.  
  18. // Left eye
  19. g.fillOval(100, 100, 20, 30);
  20.  
  21. // Right eye
  22. g.fillOval(180, 100, 20, 30);
  23.  
  24. // Straight-line nose
  25. g.drawLine(155, 125, 155, 155);
  26.  
  27. // Smile
  28. g.drawArc(100, 130, 100, 70, 180, 180);
  29. }
  30.  
  31. public static void main(String[] args) {
  32.  
  33. JFrame frame = new JFrame("Smiley");
  34.  
  35. Smiley smiley = new Smiley();
  36.  
  37. frame.add(smiley);
  38. frame.setSize(350, 350);
  39. frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  40. frame.setVisible(true);
  41. }
  42. }
Success #stdin #stdout 0.03s 25344KB
stdin
Standard input is empty
stdout
import javax.swing.*;
import java.awt.*;

public class Smiley extends JPanel {

    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);

        // Face
        g.setColor(Color.YELLOW);
        g.fillOval(50, 50, 200, 200);

        // Face outline
        g.setColor(Color.BLACK);
        g.drawOval(50, 50, 200, 200);

        // Left eye
        g.fillOval(100, 100, 20, 30);

        // Right eye
        g.fillOval(180, 100, 20, 30);

        // Straight-line nose
        g.drawLine(155, 125, 155, 155);

        // Smile
        g.drawArc(100, 130, 100, 70, 180, 180);
    }

    public static void main(String[] args) {

        JFrame frame = new JFrame("Smiley");

        Smiley smiley = new Smiley();

        frame.add(smiley);
        frame.setSize(350, 350);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);
    }
}