展开全部
试了一下,从网上找了个GIF
可以用啊
--------------------------------------------------------------------------------------------
import java.awt.Graphics;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class ImageApp extends JFrame {
public ImageApp() {
62616964757a686964616fe59b9ee7ad9431333330326663setDefaultCloseOperation(EXIT_ON_CLOSE);
setLocationRelativeTo(null);
setSize(400, 300);
setResizable(false);
getContentPane().setLayout(null);
JPanel panel = new ImagePanel();
panel.setBounds(0, 0, 400, 300);
getContentPane().add(panel);
setVisible(true);
}
public static void main(String[] args) {
new ImageApp();
}
class ImagePanel extends JPanel {
public void paint(Graphics g) {
super.paint(g);
// ImageIcon icon = new ImageIcon("D:\\1.jpg");
ImageIcon icon = new ImageIcon("D:\\14405937jqhjsppeninjf9.gif");
g.drawImage(icon.getImage(), 0, 0, 400, 300, this);
}
}
}