这就是我到目前为止所拥有的。我已经阅读了有关绘图和创建图像的 oracle 文档,但我仍然无法弄清楚。
final BufferedImage image = ImageIO.read(new File("BeachRoad_double_size.png"));
final JPanel pane = new JPanel();
frame.add(pane);
int delay = 1000; //milliseconds
ActionListener taskPerformer = new ActionListener() {
public void actionPerformed(ActionEvent evt) {
Graphics gg = image.getGraphics();
System.out.println("sdfs");
pane.paintComponents(gg);
//g.drawImage(image, 0, 0, null);
}
};
new Timer(delay, taskPerformer).start();