当前位置: 技术问答>java相关
请问为什么Image要刷新一次才能显示?
来源: 互联网 发布时间:2017-04-13
本文导语: public void paint(Graphics g) { Image image = getImage(getCodeBase(), "image\2.gif"); g.drawImage(image,10,10,null); } 请问上面的代码那里有问题,IE必须刷新一次才能显示图片。 | 建议使用图形...
public void paint(Graphics g)
{
Image image = getImage(getCodeBase(), "image\2.gif");
g.drawImage(image,10,10,null);
}
请问上面的代码那里有问题,IE必须刷新一次才能显示图片。
{
Image image = getImage(getCodeBase(), "image\2.gif");
g.drawImage(image,10,10,null);
}
请问上面的代码那里有问题,IE必须刷新一次才能显示图片。
|
建议使用图形双缓存
例程序:
import java.applet.Applet;
import java.awt.*;
public class advertise extends Applet{
private Label prompt1, prompt2;
private double t;
private Choice choicePages;
private TextField inputTime;
private boolean judge = false;
private Image pic[];
private int totalImages = 30, currentImage = 0, sleepTime = 1000;
private Graphics gContext;
private Image buffer;
public void init(){
prompt1 = new Label("Please choice how many advertisement page do you want to see:");
prompt2 = new Label("Enter how much time do you want to see each page:");
choicePages = new Choice();
inputTime = new TextField("1.0",4);
pic = new Image[totalImages];
buffer = createImage(800, 600);
gContext = buffer.getGraphics();
gContext.setColor(Color.white);
gContext.fillRect(0, 0, 800, 600);
for(int i = 0; i
例程序:
import java.applet.Applet;
import java.awt.*;
public class advertise extends Applet{
private Label prompt1, prompt2;
private double t;
private Choice choicePages;
private TextField inputTime;
private boolean judge = false;
private Image pic[];
private int totalImages = 30, currentImage = 0, sleepTime = 1000;
private Graphics gContext;
private Image buffer;
public void init(){
prompt1 = new Label("Please choice how many advertisement page do you want to see:");
prompt2 = new Label("Enter how much time do you want to see each page:");
choicePages = new Choice();
inputTime = new TextField("1.0",4);
pic = new Image[totalImages];
buffer = createImage(800, 600);
gContext = buffer.getGraphics();
gContext.setColor(Color.white);
gContext.fillRect(0, 0, 800, 600);
for(int i = 0; i