Topic: 图片循环显示问题 |
Print this page |
1.图片循环显示问题 | Copy to clipboard |
Posted by: itzy Posted on: 2005-01-15 21:22 import javax.swing.*; import java.awt.*; class One extends JFrame { JLabel jj; JPanel pp; public One() { jj=new JLabel(); pp=new JPanel(); pp.add(jj); Container cc=getContentPane(); cc.add(pp); } void display(ImageIcon n) { for(int i=0;i<i+1;i++) { try { jj.setIcon; Thread.sleep(1000); } catch(InterruptedException e) {} } } public static void main(String args[]) { One rr=new One(); rr.setSize(400,300); rr.show(); } } class Two implements Runnable { ImageIcon nnn; Thread t; One one; public Two(ImageIcon n) { nnn=n; one=new One(); t=new Thread(this); t.start(); } public void run() { synchronized(one) { one.display(nnn); } } public static void main(String args[]) { ImageIcon aa=new ImageIcon("a.gif"); ImageIcon bb=new ImageIcon("b.gif"); ImageIcon cc=new ImageIcon("c.gif"); Two t1=new Two(aa); Two t2=new Two(bb); Two t3=new Two(cc); } } 为什么没有循环显示? |
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 |