Gadgets

Monday, 15 October 2012

smile symbol using threads

SMILE SYMBOL  

import java.awt.*;
import java.lang.*;

public class SmileIcon {
   public static void main(String a[])
   {
     MySmile i=new MySmile(); 
   }
}
class MySmile extends Frame implements Runnable//runnable is an inteface we crate threads using thread class and Runnable interface
{
   
    Thread t;//thread is a class
    MySmile()
    {
        this.setBackground(Color.red);//background color for frame
      this.setTitle("smile icon");//title
      this.setSize(600,600);//size of the frame(x,y)
      this.setVisible(true);//frame visibility  is true
      t=new Thread(this);//thread is a class
      t.start();//start() method is used for start the thread
     
    }
    public void paint(Graphics g)//pain is a method. it is used for draw the images and text
    {
        g.setColor(Color.yellow);//set color for smile icon oval
        g.fillOval(50,50,50,50);//smile icon oval size(x,y,width,height)
        g.setColor(Color.white);//set color for eyes
         g.fillOval(60,64,10,10);//eye size(x,y,width,height)
        g.fillOval(80,64,10,10);// " "
        g.setColor(Color.black);//set color for smile icon eye and arc
        g.fillOval(63,66,4,4);//eye size(x,y,width,height)
        g.fillOval(83,66,4,4);// " "
       
         g.setColor(Color.red);
        g.drawArc(60,55,30,30,-65,-65);//arc size(x+width,y+height,width,height,start angle,arc angle)
     
    }
     public void run()//run() is a method to run thread
        {
       
        }
}

OUTPUT

No comments:

Post a Comment