0
try {
ImageIcon ico2=new ImageIcon("src/on1.png");
jLabel42.setIcon(ico2);
Thread.sleep(100);
ImageIcon ico3=new ImageIcon("src/on2.png");
jLabel42.setIcon(ico3);
Thread.sleep(100);
ImageIcon ico4=new ImageIcon("src/on3.png");
jLabel42.setIcon(ico4);
Thread.sleep(100);
ImageIcon ico5=new ImageIcon("src/on4.png");
jLabel42.setIcon(ico5);
Thread.sleep(100);
ImageIcon ico7=new ImageIcon("src/on5.png");
jLabel42.setIcon(ico7);
Thread.sleep(100);
ImageIcon ico8=new ImageIcon("src/on6.png");
jLabel42.setIcon(ico8);
Thread.sleep(100);
ImageIcon ico9=new ImageIcon("src/on7.png");
jLabel42.setIcon(ico9);
Thread.sleep(100);
ImageIcon ico10=new ImageIcon("src/on8.png");
jLabel42.setIcon(ico10);
Thread.sleep(100);
ImageIcon ico6=new ImageIcon("src/on1.png");
jLabel42.setIcon(ico6);
OffOn1=1;
} catch (InterruptedException ex) {
}
此代碼的工作一樣:
Thread.sleep(900);
ImageIcon ico6=new
ImageIcon("src/on1.png");
jLabel42.setIcon(ico6);
OffOn1=1;
我的問題是,爲什麼!?
問題的標題是「爲什麼我的JLabel動畫不起作用?」 - 它實際上工作與否? – msrd0 2014-10-05 16:57:40
如果您在EDT中運行此操作,GUI將在您的方法運行時鎖定,並且在完成之前不會重新繪製標籤。 – 2014-10-05 16:58:27