快手视频封面多条文字:java里怎么让显示的图片移动?(让plane移动)

来源:百度文库 编辑:高考问答 时间:2024/04/29 00:05:33
import java.awt.*;
import java.applet.*;

public class DrawImage2 extends Applet{
Image Background,Plane;
int x,y,sx,sy,ww,hh;
public void init()
{ x=y=0;
sx=10;
sy=10;
ww=getSize().width;
hh=getSize().height;

Background=getImage(getCodeBase(),"Images/123.jpg");
Plane=getImage(getCodeBase(),"Images/234.jpg");

}
public void paint(Graphics g)
{
g.drawImage(Background,0,0,getSize().width,getSize().height,this);
g.drawImage(Plane,0,0,this);

x=x+sx;
y=y+sy;
if(x>=ww||x<0) sx=-sx;
if(y>=hh||y<0) sy=-sy;
g.Plane(x,y,ww,hh);
try
{
Thread.sleep(40); //程序休眠40毫秒
}
catch(InterruptedException E){}
repaint(); //请求系统重画

}