Tuesday, 29 November 2011

Growing text

import java.awt.*;
import java.applet.*;

//<applet code="Growing" height=700 width=800> </applet>

public class Growing extends Applet
{
    int size=10;
    Thrd tt=new Thrd();
    Image img;
    public void init()
    {
        tt.start();
        img=getImage(getDocumentBase(),"Water lilies.jpg");
    }
   
   
    public void paint(Graphics g) 
    {
        g.setColor(Color.yellow);
        g.setFont(new Font("Arial",Font.BOLD,size));
        g.drawImage( img, size,size ,this);
        g.drawString("Welcome to All",200,350);
    }
    public void destroy()
    {
        tt.stop();
        System.out.print("finished");
       
    }


    class Thrd extends Thread
    {
        public void run()
        {
            do
            {
                try
                {
                    Thread.sleep(200);
                    size++;
                    if(size==70) size=10;
                    repaint();
                }
                catch(InterruptedException ie)
                {
                    System.out.println ("Thread Exception");
                }
            }while(true);
        }
    }
}

No comments:

Post a Comment