Java/swing:能不能用如下代码实现JLabel上的图片显示两秒后消失?如果不能应该怎么写啊?谢谢~
ImageIcon myimage = new ImageIcon("queen.jpg");myimage.setImage(myimage.getImage().getScaledInstance(50, 50, Image.SCALE_DEFAULT));
lblNewLabel.setIcon(myimage);
try{
Thread.sleep(2000);
}catch(InterruptedException e){
System.out.println("There is a exception.");
}
lblNewLabel.setIcon(null); --------------------编程问答-------------------- ImageIcon icon = new ImageIcon(ImageIO.read(new File("queen.jpg")).getScaledInstance(50,50,Image.SCALE_DEFAULT));
jlabel.setIcon(icon);
javax.swing.Timer timer = new javax.swing.Timer(2000,new ActionListener(){
public void actionPerformed(ActionEvent e){
jlabel.setIcon(null);
}
});
timer.setRepeats(false);
timer.start(); --------------------编程问答-------------------- 哦,这样啊,谢谢啊~~
补充:Java , Java SE