How to create Java Smiley Swing

By |2018-10-27T09:16:18+05:30November 21st, 2017|java|

In this tutorials, I am going to show you how to create a Java smiley face using the swing.

Java Smiley using Swing :
import java.awt.Color;
import java.awt.Graphics;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;

public class Smiley extends JPanel {

    public void paintComponent(Graphics g) {
        g.fillOval(10, 10, 200, 200);

        // draw Eyes
        g.fillOval(55, 65, 30, 30);
        g.fillOval(135, 65, 30, 30);

        // draw Mouth
        g.fillOval(50, 110, 120, 60);

        // adding smile
        g.fillRect(50, 110, 120, 30);
        g.fillOval(50, 120, 120, 40);

    public static void main(String[] args) {
        Smiley smily = new Smiley();
        JFrame app = new JFrame();
        app.setSize(300, 300);

Output :

Smiley Java Swing

Happy Learning 🙂

About the Author:

Hi Folks, you have reach this so far, that shows you like what you are learning. Then why don't you support us to improve for bettor tutorials by leaving your valuable comments and why not you keep in touch with us for latest updates on your favorite blog @ facebook , twitter , Or Google+ ,

Leave A Comment