1 private Image offImage = new BufferedImage(800, 700, BufferedImage.TYPE_INT_RGB);//在内存中new一张图片出来
1 public void paint(Graphics g) { 2 Graphics offG = offImage.getGraphics();//得到内存图片的画笔 3 super.paint(offG); 4 for (Shape shape : shapes) { 5 if (shape != null) { 6 shape.draw(offG);//把图形画到内存图片上 7 } 8 } 9 g.drawImage(offImage,0,0, null);//把内存中的图片画到屏幕上 10 }
时间: 2024-10-12 15:30:09