Topic: 大侠们,帮我看看哪错了呀

  Print this page

1.大侠们,帮我看看哪错了呀 Copy to clipboard
Posted by: ice0819
Posted on: 2009-04-02 20:10

import java.awt.*;

class ToolkitTest extends Frame
{
Image [] images=new Image[4];
String [] names={"1.jpg","2.jpg","3.jpg","4.jpg"};

ToolkitTest()
{

while(true)
{
for(int i=0;i<names.length;i++)
images[i]= this.getToolkit().getImage(names[i]);
repaint();
}
setSize(500,450);
setVisible(true);

}

public void update(Graphics g){paint(g);}

public void paint(Graphics g)
{

int x=(int)Math.random()*480;
int y=(int)Math.random()*420;
g.drawImage(images[(int)Math.random()*4],x,y,null);
}

public static void main(String args[]){new ToolkitTest();}
}

2.Re:大侠们,帮我看看哪错了呀 [Re: ice0819] Copy to clipboard
Posted by: ice0819
Posted on: 2009-04-02 20:13

图片处是 paint(g)

3.Re:大侠们,帮我看看哪错了呀 [Re: ice0819] Copy to clipboard
Posted by: yanglijuanylj
Posted on: 2009-04-07 17:36

要是你的还是不能运行的话,你就把 setSize(500,450);setVisible(true); 这两句放在 while(ture) 前面.

4.Re:大侠们,帮我看看哪错了呀 [Re: ice0819] Copy to clipboard
Posted by: yanglijuanylj
Posted on: 2009-04-07 17:37

要是你的还是不能运行的话,你就把 setSize(500,450);setVisible(true); 这两句放在 while(ture) 前面. 可能会根据你的运行工具的差异而要改下的.


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923