当前位置: 技术问答>java相关
在applet里,怎么让一张图片渐渐消失,然后又渐渐显示呢?
来源: 互联网 发布时间:2017-04-24
本文导语: 如题 | import java.applet.*; import javax.swing.*; import java.awt.*; import java.awt.image.*; import java.awt.event.*; import java.util.*; public class applet2 extends Applet implements Runnable { Image img[]=new Image[30]; Image im...
如题
|
import java.applet.*;
import javax.swing.*;
import java.awt.*;
import java.awt.image.*;
import java.awt.event.*;
import java.util.*;
public class applet2 extends Applet implements Runnable {
Image img[]=new Image[30];
Image imgx=null;
int imgIndex=0;
int imgAdd=1;
Thread thread=null;
MediaTracker mt;
ImageFilter imgf=null;
FilteredImageSource fis=null;
Image im=null;
Graphics g2=null;
public void init() {
imgx=this.getImage(this.getCodeBase(),"d.jpg");
mt=new MediaTracker(this);
thread=new Thread(this);
loadImage(mt);
try {
mt.waitForAll();
} catch(Exception ex) {System.err.println(ex.toString());}
im=this.createImage(imgx.getWidth(this),imgx.getHeight(this));
g2=im.getGraphics();
}
public void loadImage(MediaTracker mt) {
for(int i=0;i=29)
imgAdd=-1;
if(imgIndex
import javax.swing.*;
import java.awt.*;
import java.awt.image.*;
import java.awt.event.*;
import java.util.*;
public class applet2 extends Applet implements Runnable {
Image img[]=new Image[30];
Image imgx=null;
int imgIndex=0;
int imgAdd=1;
Thread thread=null;
MediaTracker mt;
ImageFilter imgf=null;
FilteredImageSource fis=null;
Image im=null;
Graphics g2=null;
public void init() {
imgx=this.getImage(this.getCodeBase(),"d.jpg");
mt=new MediaTracker(this);
thread=new Thread(this);
loadImage(mt);
try {
mt.waitForAll();
} catch(Exception ex) {System.err.println(ex.toString());}
im=this.createImage(imgx.getWidth(this),imgx.getHeight(this));
g2=im.getGraphics();
}
public void loadImage(MediaTracker mt) {
for(int i=0;i=29)
imgAdd=-1;
if(imgIndex