I am found a gif i wanted to add into one of my java programs. When I run it the picture shows up and works, but it leaves a trail behind it ( it isn't actually replacing the white behind the picture) and the window is incorrectly sized. I searched before but nothing fixed it.
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://ift.tt/1AYoBns");
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);
}
}
what would I add in to make the window the correct size and how would i repaint it?
Aucun commentaire:
Enregistrer un commentaire