Trying to create an undo function using an arraylist.
Hello everyone first time poster, just looking for some help to make sure I'm doing this in the right way. So down to business. I'm trying to create an undo function for an image program using an arraylist which stores the image. Now the normal command for saving the image is this: "imagePanel.setImage(currentImage)"
CurrentImage is the name of the class which I have created the arraylist was. Now before and after everytime a change is made to the image I save the image into the arraylist using this command: "images.add(currentImage)" images is the name of the arraylist so my undo method then has the following: "imagePanel.setImage(images.get(images.size()-1)"
This however doesn't seem to work at all and it's beginning to get just a little frustrating so I was wondering if I'm on the right track at all before I froth at the mouth. Thanks in advance for any help!