我是新來的java,我有很多問題試圖顯示圖像到我的程序。 我把圖像在適當的地圖並將它們放入數組:Java:從陣列的DrawImage
private Image[] images;
images = new Image[9];
images[0] = new ImageIcon("images/hang1.png").getImage();
images[1] = new ImageIcon("images/hang2.png").getImage();
images[2] = new ImageIcon("images/hang3.png").getImage();
接下來的部分,我不能設法得到圖像顯示在所有。我嘗試了多種選擇,但沒有成功。
public void paintComponent(Graphics g)
{
super.paintComponent(g);
int count = 0;
g.drawImage(images[count], 50, 50, ImageObserver);
count++;
}
任何解決方案,這將是非常歡迎! 親切的問候。
爲什麼你有3張圖片。你的代碼會繪製第一幅圖像。 – Horcrux7 2010-11-07 20:05:50