public void saveImage(String path){
BufferedImage image = (BufferedImage) createImage(500, 500);
Graphics gImage = image.getGraphics(); //<<<<<<<<--- exception
paint(gImage);
image = image.getSubimage(0,0,500,500);
try {
ImageIO.write(image, "png", new File(path+".png"));
}
catch (Exception e){}
}
問題在哪裏?BufferedImage的getGraphics()中的空指針異常?
謝謝,但我需要更多的幫助.. 我使用計時器來顯示JPanels arraylist,當計時器停止方法.isDisplayable()返回false和異常出現,否則圖像被保存.. 。 所以我該怎麼做 ?? – Dawnlight 2011-05-05 07:46:44