Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • Saandeep Sreerambatla

    Saandeep Sreerambatla

    @saandeep-sreerambatla-hWHU1M Sep 25, 2010

    Hi Please avoid using sms text on CE!!!

    I edited your post!

  • sowmyanatarajan

    sowmyanatarajan

    @sowmyanatarajan-AvOd15 Sep 25, 2010

    ok sure please send program as soon as possible

  • Kaustubh Katdare

    Kaustubh Katdare

    @thebigk Sep 25, 2010

    ..thread moved to CS/IT engineering section. I guess any standard JAVA book will have many JAVA programs with applets and threads. Have you referred to any?

  • sowmyanatarajan

    sowmyanatarajan

    @sowmyanatarajan-AvOd15 Sep 25, 2010

    Ya i referred. but i need a combined program using applet and threads.

  • Manish Goyal

    Manish Goyal

    @manish-r2Hoep Sep 25, 2010

    have a look

    If you find difficulty in any part ,feel free to ask

    import java.applet.*;
    import java.awt.*;
    /*<APPLET CODE="k.java" HEIGHT=400 WIDTH=900></APPLET>*/
    public class k extends Applet implements Runnable
    {
        Image img[]=new Image[2],p;
        int x=0,y=0,limit=20,i,width=60,height=60;
        int ext=(limit*limit)+width;
        Thread t,t1;
        public void init()
        {
            img[0]=getImage(getDocumentBase(),"Desert.jpg");
            img[1]=getImage(getDocumentBase(),"Hydrangeas.jpg");
        }
        public void start()
        {
            t=new Thread(this);
            t.start();
        }
    
        public void run()
        {
        try{
            for(i=0;i<2;i++)
            {        x=0;
    
            
            for(int j=0;j<=limit;j++)
            {
                p=img[i];
                t.sleep(50);
                repaint();
                x=x+20;
            }
            limit=limit-1;
            }
    
    
        
            }catch(Exception e){}
    }
    
    
    public void paint(Graphics g)
        {
            if(i==0)
            {
                g.drawImage(p,x,30,width,height,this);
            }
            if(i>=1)
            {
                g.drawImage(p,x,30,width,height,this);
                g.drawImage(img[0],ext,30,width,height,this);
            }
        }
    
    }
    
  • Kaustubh Katdare

    Kaustubh Katdare

    @thebigk Sep 26, 2010

    Goyal, please refrain from providing ready-made help. Instead, you may help the members code the program on their own. This can be done by providing tips and information. It's bit of a hard work, but it will help in creating better computer engineers (in small way).

  • Manish Goyal

    Manish Goyal

    @manish-r2Hoep Sep 26, 2010

    Ok sir
    i will take care off this next time