Saturday, November 24, 2012

Drawing Bebek bahasa pemerograman java

/**
 * Drawing Bebek
 *
 * @Author  : Deni UTama
 * @Version : 14 November 2012
 */

import javax.swing.*;
import java.awt.*;
class Gambar extends Canvas
{
    public void paint(Graphics g)
    {
        g.setColor(Color.white);
        {
            g.fillRect(0,0,800,600); //Background
        }

        //Induk Bebek
        g.setColor(Color.red);
        {
            g.fillOval(40,160,40,25); //Mulut Bebek
        }
        g.setColor(Color.yellow);
        {
            g.fillOval(53,110,80,80); //Kepala Bebek
            g.fillOval(117,100,240,170); //Badan Bebek
            g.fillOval(100,150,50,50); //Leher
        }
        g.setColor(Color.blue);
        {
            g.fillOval(70,133,10,10); //Mata Bebek
        }
        g.drawString ("waii..kasiaann,,,,ibuk aku gx punya kaki..!!",300,400); //Tulisan

        //Anak Bebek
        g.setColor(Color.red);
        {
            g.fillOval(370,268,20,9); //Mulut Bebek
        }
        g.setColor(Color.yellow);
        {
            g.fillOval(390,268,20,20); //Leher
            g.fillOval(375,250,35,35); //Kepala Bebek
            g.fillOval(400,250,90,63); //badan bebek
        }
        g.setColor(Color.orange);
        {
            g.fillArc(430,305,30,30, 0, 45); //Telapak 1
            g.fillArc(415,305,30,30, 0, 45); //Telapak 2
        }
        g.setColor(Color.blue);
        {
            g.fillOval(384,260,5,5); //Mata Bebek
        }
        g.drawString ("waii..kasiaann,,,,ibuk aku gx punya kaki..!!",300,400); //Tulisan
    }
}


class Layar extends JFrame
{
    private Gambar gambar = new Gambar();
    public Layar()
    {
        super("Deny's Creativity");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setLocation(100,100);
        setSize(800,500);
       
        add(gambar);
        setVisible(true);
    }
}

public class DeniBebek
{
    public static void main(String[]args)
    {
        new Layar();
    }
}