⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 daoying.java

📁 Java程序设计实用教程源代码 本书源代码按章分别放置在不同的文件夹中,所有程序均在JDK1.6环境下编译运行正常,除了第13章需要建立ODBC数据源之外,其他程序只要有Java运行环境即可直接运行
💻 JAVA
字号:
import java.applet.Applet;
import java.awt.*;
public class daoying extends Applet {
  Image image1,image2;
  Thread thread;
  Graphics gContext;
  int width,height;
  public void init() {
    image1=getImage(getCodeBase(),"aa.jpg");
    MediaTracker tracker=new MediaTracker(this);
    tracker.addImage(image1,0);
    try{
      tracker.waitForID(0);
    }
    catch(InterruptedException e){}
    width=image1.getWidth(this);
    height=image1.getHeight(this)/2;
    image2=createImage(2*width,height);
    gContext=image2.getGraphics();
    gContext.drawImage(image1,0,-height,this);
    for(int i=0;i<height;i++)
      gContext.copyArea(0,i,width,1,width,(height-1)-2*i);
    gContext.clearRect(0,0,width,height);
  }
  public void start(){
    if(thread==null){
      thread=new Thread();
      thread.start();
    }
  }
  public void stop(){
    if(thread!=null)
      thread=null;
  }
  public void run(){
    int dy,num=0;
    double d;
    while(true){
      d=num*Math.PI/12;
      for(int i=0;i<height;i++){
        dy=(int)((i/12.0D+1)*Math.sin(height/12.0D*(height-i)/(i-1)+d));
        gContext.copyArea(width,i+dy,width,1,-width,-dy);
      }
      repaint();
      num=++num%12;
      try{
        Thread.sleep(100);
      }
      catch(InterruptedException e){}
    }
  }
  public void update(Graphics g){
    paint(g);
  }
  public void paint(Graphics g){
    g.drawImage(image1,0,-height,this);
    g.drawImage(image2,-width,height,this);
  }
}

⌨️ 快捷键说明

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