这是我使用载入名为“boat.png”加载图像
@Override
public void paint(Graphics g) {
BufferedImage img = null;
try {
img = ImageIO.read(new File("boat.png"));
} catch (IOException e) {
System.out.println("Can't load the image");
}
}
这两条线产生错误
BufferedImage img = null;
img = ImageIO.read(new File("boat.png"));
的图像。虽然我已经包括
代码import java.io.*;
import java.awt.*;
请帮我找到错误!
你需要告诉我们的错误。请阅读http://tinyurl.com/so-list –
错误是(找不到符号:BufferedImage&ImageIO) – InspiringProgramming
你不应该重写'paint',使用'JPanel'并重写'paintComponent'并且不要忘记尊重通过调用'paintComponent'超级实现作为第一次调用覆盖的方法来绘制链条 –