at.~jav

来自「经典的java applet小程序下来看看说不定有启发哦」· ~JAV 代码 · 共 44 行

~JAV
44
字号
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
public class At extends Applet implements Runnable{
   int delay;
   Thread  Thread1;
   Image[] mI=new Image[1];
   int x=50;
   int y=50;
   public void init(){
      mI=getImage(getDocumentBase(),"p1.gif");
   }
   public void start(){
      thread1 = new Thread(this,"t1");
      thread1.start();       
   }
   public void run() {
   // String s = Thread.currentThread().getName();
    System.out.println("----------"+ t1 + "----"); 

   
      while(true){
        repaint();
        try{
          Thread.sleep(2000);
        }catch(InterruptedException e){}
      
      } 
   }
   public void paint(Graphics g)  {
      x=x+50;y=y+50;
    g.drawImage(mI,x,y,this);
    //显示当前序号的图片
   // currentImage = ++currentImage % totalImages; 
    //计算下一个应显示图片的序号
  }
  
   public void stop(){
    //thread1.stop();不提倡使用
    //thread2.stop();
    thread1=null;
   } 
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?