Re: Animated Gif help 
Author: noah.w 
In Reply To: Animated Gif help 
Mar 24, 2002 2:11 AM ? 
Reply 20 of 22Try this:import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.image.*;
 
public class AnimS extends JFrame

Image      img;
ImageIcon  org = new ImageIcon("search2.gif");
JLabel     jl;
JButton    bt; 

public AnimS()
{
super();
getContentPane().setLayout(null);
setBounds(6,6,540,440);
addWindowListener(new WindowAdapter() 
    { public void windowClosing(WindowEvent ev) 
{
dispose();      
System.exit(0); 
}}); jl = new JLabel(org);
jl.setBounds(30,30,32,32);
getContentPane().add(jl);

bt = new JButton("Click to stop");
bt.setBounds(130,30,160,24);
getContentPane().add(bt); bt.addActionListener(new ActionListener() 
{ public void actionPerformed( ActionEvent e ) 
{
if (jl.getIcon() == org)
{
  img = jl.createImage(32,32); 
jl.printAll(img.getGraphics());
  jl.setIcon(new ImageIcon(img));
bt.setText("Click to start");
}
else
{
bt.setText("Click to stop");
(jl.setIcon(org));
}
}
});
 
setVisible(true);
 
}
public static void main (String[] args) 
{
new AnimS();   
}
}   
 
Noah

解决方案 »

  1.   

    masterz?????????????????????????????????????????????????????????????
      

  2.   

    to masterz():非常谢谢!可惜还是解决不了我的问题。因为我现在在做的JAVA程序是要拿到WinCE平台上运行的,所以只能用JDK1.1.8,只能用到AWT里的类,而不能用到SWING里的类。所以您说的方法解决不了我的问题。请问你还有其他方法吗?谢谢!