Monday , December 11 2017
Home / java / How to create Java Smiley Swing

How to create Java Smiley Swing

In this tutorials I am going to show you how to create a Java smiley face using 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 chandrashekhar

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+ ,


Java Graphics2D Class Example

In this tutorials, we are going to see how to use Java Graphics2D class. Java …

Leave a Reply

Your email address will not be published. Required fields are marked *