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