尝试在java中显示图像,但上面列出的错误会不断弹出。我该如何解决?
import javax.swing.*;
import java.awt.*;
public class ImageObserver{
public void paintComponent (Graphics g) {
Image image = new ImageIcon("Hyperspace.JPEG").getImage();
g.drawImage(image, 3, 4, this);
}
public static void main(String[] args) {
JFrame frame = new JFrame();
JPanel panel = new JPanel();
frame.getContentPane().add(panel);
frame.setSize(1000, 1000);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}