Topic: 线程换图问题 |
Print this page |
1.线程换图问题 | Copy to clipboard |
Posted by: yzhxhwt Posted on: 2006-01-12 12:07 我想做一个程序基于JFrame,用JLabel显示两张图片,图片隔两秒种换一次,请问如何用线程来做?谢谢 我下面的程序没做完,请大家帮帮忙: import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.applet.*; import java.net.URL; import javax.swing.event.*; class Demo extends JFrame { Demo() { MyPanel mp=new MyPanel(); new Thread(mp).start(); this.getContentPane().add(mp); setSize(400,300); setVisible(true); } public static void main(String[] args) { Demo dm=new Demo(); } } class MyPanel extends JPanel implements Runnable { //JLabel jlbl; public void run() { URL u; try { u=Class.forName("Demo").getResource("donghua/1.gif"); // Image img=this.getToolkit().getImage; // Thread.sleep(2000); // u=Class.forName("Demo").getResource("donghua/2.gif"); } catch (Exception ex) { ex.printStackTrace(); } } } |
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 |