The question I would like to ask is what is the "way" to do "history". The thingy with CTRL+Z, Y. Do I store copies of my data every time I change something? But that seems to me that doing that would destroy the memory.

Do I just record what actions were done and reverse them? I tried this, and it seems not to work very properly.

Look at every text editor, for example. They save every single letter you changed (or they should), but generally they group the saved letters by words. I would do this for your program. Instead of saving every tiny change, group together a few small changes. But you have to be careful because you need to only group small changes, as larger changes are far more significant in some cases.

However, my way is still flawed because some smaller changes might also be important. Maybe instead of saving them to memory, you should save them to file. Open a file when the program is started, assign every joint an id and then use that id and save the new modified joint angles/positions/whatever else to the file. When the user presses the back button, simply loop backwards through the text file, getting every id and then assigning the old attributes to that specific joint. When the user exits the program, close the file.

Optional: Save the file to disk when the program exits, or at regular intervals so that if the user experiences a power outage most of their data will still be there.

I came across this article recently on the Command Pattern. I haven't used it yet, but one of the things the pattern apparently enables is a method of undo/redo. The site that article comes from, Game Programming Patterns, has a number of great articles on general game programming and architecture.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org