📄 movie1.java
字号:
import java.awt.*;import java.applet.*;public class Movie1 extends Applet implements Runnable{ Image img[]=new Image[2]; int current=0; Thread newThread; Image buffer; Graphics gContext; public void init() { buffer=createImage(getWidth(),getHeight()); gContext=buffer.getGraphics(); for(int i=1;i<3;i++) { img[i-1]=this.getImage(getCodeBase(),"c"+i+".jpg"); } } public void start() { if(newThread==null) { newThread=new Thread(this); newThread.start(); } } public void stop() { if(newThread!=null) newThread=null; } public void run() { while(true) { gContext.drawImage(img[current],100,200,this); repaint(); try { newThread.sleep(500) ; }catch(InterruptedException e){} gContext.clearRect(100,20,100,100); current=++current%2; } } public void paint(Graphics g) { g.drawImage(img[current],0,0,this); } public void update(Graphics g) { paint(g); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -