【发布时间】:2018-01-22 20:57:06
【问题描述】:
您好,我不确定如何格式化我的动画 gif 图像以让它们显示在 eclipse 上创建的罐子上。
try {
//ImageIcon titleIcon = new ImageIcon(ImageIO.read(getClass().getResource("title.gif")));
title = new ImagePicture (new ImageIcon(ImageIO.read(getClass().getResource("title.gif"))), 0, 0);
//title = new ImagePicture (new ImageIcon("title.gif"), 0, 0);
}//end try
catch (IOException e) {
}//end catch
//set title bounds
title.setBounds(260, 0, 400, 100);
这是我现在的 GIF 动画代码,感谢您的输入。
【问题讨论】:
-
您要查找的搜索词是“Swing 中的动画 gif”。 Eclipse(您的 IDE)和 jars(您的运行时)与此处无关。
-
ImageIO不支持动画 Gif,至少不支持任何合理的方式,而直接使用ImageIcon是无法实现的。相反,将URL从getResource直接传递给ImageIcon
标签: java jar animated-gif