⑴ java怎麼在JFrame中顯示動態圖片
試了一下,從網上找了個GIF
可以用啊
--------------------------------------------------------------------------------------------
importjava.awt.Graphics;
importjavax.swing.ImageIcon;
importjavax.swing.JFrame;
importjavax.swing.JPanel;
{
publicImageApp(){
setDefaultCloseOperation(EXIT_ON_CLOSE);
setLocationRelativeTo(null);
setSize(400,300);
setResizable(false);
getContentPane().setLayout(null);
JPanelpanel=newImagePanel();
panel.setBounds(0,0,400,300);
getContentPane().add(panel);
setVisible(true);
}
publicstaticvoidmain(String[]args){
newImageApp();
}
classImagePanelextendsJPanel{
publicvoidpaint(Graphicsg){
super.paint(g);
//ImageIconicon=newImageIcon("D:\1.jpg");
ImageIconicon=newImageIcon("D:\14405937jqhjsppeninjf9.gif");
g.drawImage(icon.getImage(),0,0,400,300,this);
}
}
}