我想在我的applet屏幕上添加一个包含jlabels图像的arraylist

时间:2013-12-02 05:33:18

标签: java arraylist jlabel japplet imageicon

所以我想做的是显示一个字符串hello world“(”Hello World“,i * 100,y)”我想显示我的jlabels在ArrayList中

public class FruitWarUI extends JApplet implements Runnable{     

public int WIDTH = 500, HEIGHT = 725, y=0;
BufferedImage screen = new BufferedImage(WIDTH,HEIGHT, 4);      


@Override
public void init(){
    new Thread(this).start();

}

@Override
    public void paint(Graphics g){
    screen.getGraphics().clearRect(0, 0, WIDTH, HEIGHT);
    for(int i=0; i<=5; i++) screen.getGraphics().drawString("Hello World",i*100,y);
    g.drawImage(screen, 0, 0, this);
} 

@Override
public void run(){              
    try{ 
        for(y=0; y<700; y++){ 
            Thread.sleep(10); 
            repaint();  
        } 
        run();
    } catch (Exception e) {
    } 
    }

0 个答案:

没有答案