import java.awt.Image
import java.io.File
import javax.imageio.ImageIO
import javax.swing.JFrame
public class IconFrame extends JFrame {
public IconFrame init(){
this.setDefaultCloseOperation(EXIT_ON_CLOSE)
this.setSize(300,200)
try {
Image image = ImageIO.read(new File("INPUT YOUR IMAGE FILE NAME HERE!"))
this.setIconImage(image)
} catch (Exception e) {
e.printStackTrace()
}
return this
}
public static void main(String[] args){
EventQueue.invokeLater(new Runnable(){
public void run(){
new IconFrame().init().setVisible(true)
}
})
}
}
Image img = kit.getImage("C:\\Documents and Settings\\Administrator\\桌面\\GUI\\src\1.jif")这个1.jif 应该是1.gif吧 把 g 写成了 j
另存动画的gif记得不能设,普通静态的貌似可以,一般用png
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)