If you're just talking about one level of undo - you could do that with
an offscreen bitmap.
I have used BufferedImage with much success.
BufferedImage image = new BufferedImage(xm, ym,
BufferedImage.TYPE_INT_ARGB);
DataBuffer imageBuf = ((BufferedImage)image).getRaster().getDataBuffer();
etc etc
save screen to buffer on commit, blit buffer to screen to undo......
If you want to have multiple levels of undo, you could use mulitple
buffers .....