请指教

grpengwei 2004-10-28 06:29:36
import java.awt.*;
import javax.swing.*;
import java.util.*;
public class Zcy extends JFrame
{ZcyPanel aaa=new ZcyPanel();

public Zcy()
{
super("老婆照片动动");
setBackground(Color.black);
setSize(452,146);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel pane= new JPanel();

pane.setLayout(new BorderLayout());
pane.add("Center",aaa);


setContentPane(pane);


show();
}
public static void main(String[] arguments)
{
Zcy zcy=new Zcy();


}
}
class ZcyPanel extends JPanel implements Runnable
{
Thread runner;
Image[] ima =new Image[2];
int com =0;
ZcyPanel()
{
super();


String iam[]={"mag1.JPEG","mag2.JPEG"};
for(int i=0; i<ima.length;i++)
{
Image ima=new ImageIcon(iam[i]).getImage();

}

if(runner==null){runner=new Thread(this);runner.start();}
}
public void paintComponent(Graphics g)
{
Graphics2D g2D =(Graphics2D)g;

for(int com=0;com<ima.length;com++){if(ima[com]!=null)
g2D.drawImage(ima[com],0,0,this);}

}
public void run()
{
while(true)
{
pause(1500);
}
}
public void pause(int time){try{Thread.sleep(time);}catch(InterruptedException e){}}
}


为什么这个程序编译没问题
但运行时显示不了图片动画~??
请指教~!
...全文
61 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
grzhenchun 2005-05-24
  • 打赏
  • 举报
回复

81,122

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧