Følgende virker fint hos mig:
import java.awt.BorderLayout;
import java.net.MalformedURLException;
import java.net.URL;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
public class Pic extends JFrame {
public Pic() throws MalformedURLException {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
getContentPane().setLayout(new BorderLayout());
JPanel p = new JPanel();
p.add(new JLabel(new ImageIcon(new URL("
http://www.google.dk/images/nav_logo3.png"))));
getContentPane().add(p, BorderLayout.CENTER);
pack();
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
try {
Pic f = new Pic();
f.setVisible(true);
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
});
}
}