这个很简单啊,用Thread.sleep(500)不就行了

解决方案 »

  1.   


    我写了这些功能没实现,大家帮我看看,谢谢!!!!import java.applet.*;
    import java.awt.*;
    import java.lang.*;public class Myapplet extends Applet implements Runnable
    {
    Thread t;
    String s="1";
    int x=0;
    public void init()
    {
    t=Thread.currentThread();

    }
    public void paint(Graphics g)
    {
    g.drawString(s,10+x,10);

    }

    public void run()
    {

    for(int i=2;i<21;i++)
    {
    try
    {
    t.sleep(500);
    }
    catch(InterruptedException e)
    {}
    s=Integer.toString(i);
    repaint();
    x+=25;

    }
    }
    }
      

  2.   

    将init()修改如下:public void init(){
    //t=Thread.currentThread();
    t=new Thread(this);
    t.start();
    }
      

  3.   

    我描述错了
    是打印1了以后
    打印2的时候 1就没有了
    依此类推why???
      

  4.   

    String s 改为 StringBuffer s 试试。
    String s的值是不能改变的,只有StringBuffer的值才可以随意改变
      

  5.   

    import java.applet.*;
    import java.awt.*;
    public class MyApplet extends Applet {
    String s="1";
    int x=0;

    public void init(){}

    public void paint(Graphics g){
    for(int i=1;i<21;i++){
    try {
    Thread.currentThread().sleep(500);
    }catch(InterruptedException e){}
    s=Integer.toString(i);
    g.drawString(s,10+x,10);
    x+=25;
    }
    }
    }
      

  6.   

    s=s+Integer.toString(i);可以试一试!
      

  7.   

    import java.applet.*;
    import java.awt.*;
    import java.lang.*;public class Myapplet extends Applet implements Runnable
    {
    Thread t;
    String s="1";
    int x=0;
    Graphics pg; public void init()
    {
    pg = this.getGraphics();
    t=new Thread(this);
    t.start();

    }
    public void run()
    {

    for(int i=2;i<21;i++)
    {
    try
    {
    t.sleep(500);
    }
    catch(InterruptedException e)
    {}
    s=Integer.toString(i);
    pg.drawString(s,10+x,10);
    x+=25;

    }
    }
    }