samedi 16 juillet 2016

How to use Timer? [duplicate]

This question already has an answer here:

public class A extends JApplet  implements Runnable{
Thread t;
public void init(){
    //initialization
}
public void start()
{
    t = new Thread(this);
    t.start();
}
public void run()
{
    while(condition)
    {
        super.repaint();
        t.sleep(time);
    }
}
public void paint()
{
    //Draw something
    while(condition)
    {
        //draw Something
        t.sleep(time);
    }
}
}

This is my applet code. and its work fine when I run its on web page. But if I include two applet on same page then its not work. I have searched about it and get that instead of sleep() use Timer. how I do this?

Aucun commentaire:

Enregistrer un commentaire