gif图像尺寸不正确,不重新粉刷

时间:2015-03-10 00:56:41

标签: java animation jlabel gif

我发现了一个我希望添加到我的Java程序中的GIF。当我运行它时,图片显示并起作用,但它留下了一条痕迹(它实际上并没有替换图片后面的白色),并且窗口的大小不正确。我之前搜索过,但没有修复它。

package tasks;

import java.net.MalformedURLException;
import java.net.URL;

import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;


public class duane
{
    public static void main(String[] args) throws MalformedURLException {
        URL url = new URL("http://i2.kym-cdn.com/photos/images/newsfeed/000/602/307/4d3.gif");
        Icon icon = new ImageIcon(url);
        JLabel label = new JLabel(icon);

        JFrame f = new JFrame("Animation");
        f.getContentPane().add(label);
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.pack();
        f.setLocationRelativeTo(null);
        f.setVisible(true);
    }
}

我会添加什么来使窗口的大小正确,我将如何重新绘制它?

0 个答案:

没有答案
相关问题